public void FetchFriends_FacebookResultCallback(FacebookAsyncResult asyncResult) { if (asyncResult.IsCompleted && asyncResult.Error == null && asyncResult.Result != null) { lock (lstFacebookSessionMutualFriends) { lstFacebookSessionMutualFriends = lstFacebookSessionMutualFriends.Union( ((JsonArray)((JsonObject)asyncResult.Result)["data"]) .Select(o => new MutualFriendItem { FriendID = long.Parse((string)((JsonObject)o)["uid1"]), MutualFriendID = long.Parse((string)((JsonObject)o)["uid2"]) })).ToList(); } } lock (mutualFriendsQueryCount) { mutualFriendsQueryCount.Counter--; } //System.Diagnostics.Debug.WriteLine(asyncResult.Result); }
/// <summary> /// Asynchronous callback of the GetAlbum method. /// </summary> /// <param name="result">Async result.</param> private void GetAlbumAsyncCallback(FacebookAsyncResult result) { //If the user has suppressed the album, we need to re-create it in the catch block. try { JsonArray array = result.Result as JsonArray; foreach (JsonObject obj in array) { string name = obj["name"].ToString(); if (name == App.FacebookAlbumName) { string albumId = obj["object_id"].ToString(); string facebookAccessToken = IsolatedStorageSettings.ApplicationSettings["FacebookAccessToken"].ToString(); UploadPhoto(facebookAccessToken, albumId); return; } } throw new Exception(); } catch { string facebookAccessToken = IsolatedStorageSettings.ApplicationSettings["FacebookAccessToken"].ToString(); CreateAlbum(facebookAccessToken); } }
/// <summary> /// Asynchronous callback of the UploadPhoto method. /// </summary> /// <param name="result">Async result.</param> private void UploadPhotoAsyncCallback(FacebookAsyncResult result) { JsonObject obj = result.Result as JsonObject; if (PhotoSentToFacebook != null) { Deployment.Current.Dispatcher.BeginInvoke(() => { IsUploading = false; PhotoSentToFacebook(this, new EventArgs()); }); } }
/// <summary> /// Asynchronous callback of the CreateAlbum method. /// </summary> /// <param name="result">Async result.</param> private void CreateAlbumAsyncCallback(FacebookAsyncResult result) { JsonObject obj = result.Result as JsonObject; string albumId = obj["id"].ToString(); string facebookAccessToken = IsolatedStorageSettings.ApplicationSettings["FacebookAccessToken"].ToString(); UploadPhoto(facebookAccessToken, albumId); }