コード例 #1
0
        /// <summary>
        /// For platforms that do not support dynamic cast it to either IDictionary<string, object> if json object or IList<object> if array.
        /// For primitive types cast it to bool, string, dobule or long depending on the type.
        /// Reference: http://facebooksdk.net/docs/making-asynchronous-requests/#1
        /// </summary>
        public static void API(
            string endpoint,
            HttpMethod method,
            FacebookDelegate callback,
            object parameters = null)
        {
#if NETFX_CORE

            Task.Run(async () =>
            {
                FacebookClient fb = new FacebookClient(_fbSessionClient.CurrentAccessTokenData.AccessToken);
                FBResult fbResult = null;
                try
                {
                    object apiCall;
                    if (method == HttpMethod.GET)
                    {
                        apiCall = await fb.GetTaskAsync(endpoint, parameters);
                    }
                    else if (method == HttpMethod.POST)
                    {
                        apiCall = await fb.PostTaskAsync(endpoint, parameters);
                    }
                    else
                    {
                        apiCall = await fb.DeleteTaskAsync(endpoint);
                    }
                    if (apiCall != null)
                    {
                        fbResult = new FBResult();
                        fbResult.Text = apiCall.ToString();
                        fbResult.Json = apiCall as JsonObject;
                    }
                }
                catch (Exception ex)
                {
                    fbResult = new FBResult();
                    fbResult.Error = ex.Message;
                }
                if (callback != null)
                {
                    Dispatcher.InvokeOnAppThread(() => { callback(fbResult); });
                }
            });
#else
            throw new PlatformNotSupportedException("");
#endif
        }
コード例 #2
0
ファイル: MainViewModel.cs プロジェクト: peterdocter/hydra
 public async void UnlinkFaceBook()
 {
     if(!HasConnection || UserPreference.AccessKey==null)
         return; 
     var fb = new FacebookClient(UserPreference.AccessKey) { AppId = AppId };
     await fb.DeleteTaskAsync(string.Format("https://graph.facebook.com/{0}/permissions", UserPreference.FbUserId));
     UserPreference.AccessKey = null;
     UserPreference.FbUserId = null;
     UserPreference.Name = null;
     SaveSettings();
     NotifyPropertyChanged("AccessKey");
 }
コード例 #3
0
 public Task<object> DeleteFacebookRequestAsync(string requestId, long userId, string accessToken)
 {
     string final = string.Format("{0}_{1}", requestId, userId);
     var fb = new FacebookClient(accessToken);
     return fb.DeleteTaskAsync(final);
 }