private void OnLoaPlayrScoresComplete(FB_Result result) { if (result.IsFailed) { OnPlayerScoresRequestCompleteAction(result); return; } Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.RawData) as Dictionary <string, object>; List <object> data = JSON["data"] as List <object>; foreach (object row in data) { FB_Score score = new FB_Score(); Dictionary <string, object> dataRow = row as Dictionary <string, object>; Dictionary <string, object> userInfo = dataRow["user"] as Dictionary <string, object>; score.UserId = System.Convert.ToString(userInfo["id"]); score.UserName = System.Convert.ToString(userInfo["name"]); score.value = System.Convert.ToInt32(dataRow["score"]); score.AppId = System.Convert.ToString(FB.AppId); AddToUserScores(score); } OnPlayerScoresRequestCompleteAction(result); }
private void OnAppScoresComplete(FB_Result result) { if (result.IsFailed) { OnAppScoresRequestCompleteAction(result); return; } Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.RawData) as Dictionary <string, object>; List <object> data = JSON["data"] as List <object>; foreach (object row in data) { FB_Score score = new FB_Score(); Dictionary <string, object> dataRow = row as Dictionary <string, object>; if (dataRow.ContainsKey("user")) { Dictionary <string, object> userInfo = dataRow["user"] as Dictionary <string, object>; if (userInfo.ContainsKey("id")) { score.UserId = System.Convert.ToString(userInfo["id"]); } if (userInfo.ContainsKey("name")) { score.UserName = System.Convert.ToString(userInfo["name"]); } } if (dataRow.ContainsKey("score")) { score.value = System.Convert.ToInt32(dataRow["score"]); } if (dataRow.ContainsKey("application")) { Dictionary <string, object> AppInfo = dataRow["application"] as Dictionary <string, object>; if (AppInfo.ContainsKey("id")) { score.AppId = System.Convert.ToString(AppInfo["id"]); } if (AppInfo.ContainsKey("name")) { score.AppName = System.Convert.ToString(AppInfo["name"]); } } AddToAppScores(score); } OnAppScoresRequestCompleteAction(result); }
private void OnDeleteActionFinish(FB_Result result) { if(result.IsSucceeded) { State = FB_AppRequestState.Deleted; } OnDeleteRequestFinished(result); }
private void OnDeleteActionFinish(FB_Result result) { if (result.IsSucceeded) { State = FB_AppRequestState.Deleted; } OnDeleteRequestFinished(result); }
private static void FB_OnAuthCompleteAction(FB_Result res) { if (res.IsSucceeded) { SocialLoginFinished(AN_SoomlaSocialProvider.FACEBOOK, SPFacebook.Instance.UserId); } else { SocialLogin(AN_SoomlaEventType.SOOMLA_EVENT_FAILED, AN_SoomlaSocialProvider.FACEBOOK); } }
private void OnAuth(FB_Result result) { if (SPFacebook.instance.IsLoggedIn) { LoadUserData(); } else { OnFailedAuth(); } }
void GraphCallback (FBResult result) { FB_Result fb_result; if (result == null) { fb_result = new FB_Result(string.Empty, "Null Response"); } else { fb_result = new FB_Result(result.Text, result.Error); } _Callback(fb_result); }
private static void FB_HandleOnFriendsDataRequestCompleteAction(FB_Result res) { if (res.IsSucceeded) { FriendsRequest(AN_SoomlaEventType.SOOMLA_EVENT_FINISHED, AN_SoomlaSocialProvider.FACEBOOK); } else { FriendsRequest(AN_SoomlaEventType.SOOMLA_EVENT_FAILED, AN_SoomlaSocialProvider.FACEBOOK); } }
private void OnAuth(FB_Result result) { if (SPFacebook.Instance.IsLoggedIn) { IsAuntificated = true; SA_StatusBar.text = "user Login -> true"; } else { Debug.Log("Failed to log in"); } }
//scores Api events private void OnPlayerScoreRequestComplete(FB_Result result) { if (result.IsSucceeded) { string msg = "Player has scores in " + SPFacebook.Instance.userScores.Count + " apps" + "\n"; msg += "Current Player Score = " + SPFacebook.Instance.GetCurrentPlayerIntScoreByAppId(SPFacebook.Instance.AppId); SA_StatusBar.text = msg; } else { SA_StatusBar.text = result.RawData; } }
private void OnAppScoreRequestComplete(FB_Result result) { if (result.IsSucceeded) { string msg = "Loaded " + SPFacebook.Instance.appScores.Count + " scores results" + "\n"; msg += "Current Player Score = " + SPFacebook.Instance.GetScoreByUserId(SPFacebook.Instance.UserId); SA_StatusBar.text = msg; } else { SA_StatusBar.text = result.RawData; } }
private void OnDeleteScoreRequestComplete(FB_Result result) { if (result.IsSucceeded) { string msg = "Score successfully deleted" + "\n"; msg += "Current Player Score = " + SPFacebook.Instance.GetScoreByUserId(SPFacebook.Instance.UserId); SA_StatusBar.text = msg; } else { SA_StatusBar.text = result.RawData; } }
//-------------------------------------- // Internal Event Handlets //-------------------------------------- private void UserDataCallBack(FB_Result result) { if (result.IsFailed) { Debug.LogWarning(result.Error); } else { Debug.Log("[UserDataCallBack] result.RawData " + result.RawData); _userInfo = new FB_UserInfo(result.RawData); } OnUserDataRequestCompleteAction(result); }
void OnAppRequestsLoaded(FB_Result result) { if (result.Error == null) { //Printing all pending request's id's foreach (FB_AppRequest request in SPFacebook.instance.AppRequests) { Debug.Log(request.Id); } } SPFacebook.OnAppRequestsLoaded -= OnAppRequestsLoaded; }
private void FriendsDataCallBack(FB_Result result) { if (result.IsFailed) { Debug.LogWarning(result.Error); } else { ParseFriendsData(result.RawData); } OnFriendsDataRequestCompleteAction(result); }
public void LoadInvitableFrientdsInfo(int limit) { if (IsLoggedIn) { FB.API("/me?fields=invitable_friends.limit(" + limit.ToString() + ").fields(first_name,id,last_name,name,link,locale,location)", FB_HttpMethod.GET, InvitableFriendsDataCallBack); } else { Debug.LogWarning("Auth user before loadin data, fail event generated"); FB_Result res = new FB_Result("", "User isn't authed"); OnInvitableFriendsDataRequestCompleteAction(res); } }
public void LoadUserData() { if (IsLoggedIn) { FB.API("/me?fields=id,birthday,name,first_name,last_name,link,email,locale,location,gender", FB_HttpMethod.GET, UserDataCallBack); } else { Debug.LogWarning("Auth user before loadin data, fail event generated"); FB_Result res = new FB_Result("", "User isn't authed"); OnUserDataRequestCompleteAction(res); } }
// -------------------------------------- // EVENTS // -------------------------------------- private void OnLikesLoaded(FB_Result res) { //The likes is loaded so now we can find out for sure if user is like our page bool IsLikes = SPFacebook.Instance.IsUserLikesPage(SPFacebook.instance.UserId, UNION_ASSETS_PAGE_ID); if (IsLikes) { SA_StatusBar.text = "Current user Likes union assets"; } else { SA_StatusBar.text = "Current user does not like union assets"; } }
void GraphCallback(IGraphResult result) { FB_Result fb_result; if (result == null) { fb_result = new FB_Result(string.Empty, "Null Response"); } else { fb_result = new FB_Result(result.RawResult, result.Error); } _Callback(fb_result); }
private void OnFriendLoaded(FB_Result res) { if (res.Error == null) { Debug.Log("You get Friend List"); mFriendList = SPFacebook.instance.friendsList.ToArray(); if (GetFriend != null) { GetFriend("OK"); } } else { OnFriendLoadedFailed(); } }
//-------------------------------------- // EVENTS //-------------------------------------- /* * private void PermissionCallback(FBResult result) * { * FB_PermissionResult res = new FB_PermissionResult(result); * * if (!String.IsNullOrEmpty(result.Error)) * { * Debug.Log("Error Response:\n" + result.Error); * } * else * { * Debug.Log("Get user's permissions was successful!"); * * var permissionDict = Facebook.MiniJSON.Json.Deserialize(result.Text) as Dictionary<string, object>; * IDictionary persmissionData = permissionDict; * Dictionary<string, FBPermission> permissions = new Dictionary<string, FBPermission>(); * foreach(IDictionary perm in (List<object>)persmissionData["data"]) * { * FBPermission permission = new FBPermission((string)perm["permission"], * ((string)perm["status"]).Equals("granted") ? FBPermissionStatus.Granted : FBPermissionStatus.Declined); * permissions.Add (permission.Name, permission); * } * res.SetPermissions(permissions); * } * * OnPermissionsLoaded(res); * } * * private void RemovePermissionCallback(FBResult result) * { * FB_Result res = new FB_Result(result); * * if (!String.IsNullOrEmpty(result.Error)) * { * Debug.Log("Error Response:\n" + result.Error); * } * else * { * Debug.Log("RemovePermissionCallback was successful!"); * Debug.Log ("Result: "+result.Text); * } * * OnRevokePermission(res); * } * */ private void OnUserLikesResult(FB_Result result, FB_LikesRetrieveTask task) { if (result.IsFailed) { OnLikesListLoadedAction(result); return; } Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.RawData) as Dictionary <string, object>; List <object> data = JSON["data"] as List <object>; Dictionary <string, FB_LikeInfo> userLikes = null; if (_likes.ContainsKey(task.userId)) { userLikes = _likes[task.userId]; } else { userLikes = new Dictionary <string, FB_LikeInfo>(); _likes.Add(task.userId, userLikes); } foreach (object row in data) { Dictionary <string, object> dataRow = row as Dictionary <string, object>; FB_LikeInfo tpl = new FB_LikeInfo(); tpl.Id = System.Convert.ToString(dataRow["id"]); tpl.Name = System.Convert.ToString(dataRow["name"]); tpl.Category = System.Convert.ToString(dataRow["category"]); if (userLikes.ContainsKey(tpl.Id)) { userLikes[tpl.Id] = tpl; } else { userLikes.Add(tpl.Id, tpl); } } OnLikesListLoadedAction(result); }
void OnAppRequestsLoaded(FB_Result result) { if (result.IsSucceeded) { //Printing all pending request's id's foreach (FB_AppRequest request in SPFacebook.Instance.AppRequests) { Debug.Log("--------------------------"); Debug.Log(request.Id); Debug.Log(request.Message); Debug.Log(request.ActionType); Debug.Log(request.State); Debug.Log(request.Data); Debug.Log("--------------------------"); } } SPFacebook.OnAppRequestsLoaded -= OnAppRequestsLoaded; }
private void OnUserDataLoaded(FB_Result result) { SPFacebook.OnUserDataRequestCompleteAction -= OnUserDataLoaded; if (result.IsSucceeded) { SA_StatusBar.text = "User data loaded"; IsUserInfoLoaded = true; //user data available, we can get info using //SPFacebook.instance.userInfo getter //and we can also use userInfo methods, for exmple download user avatar image SPFacebook.Instance.userInfo.LoadProfileImage(FB_ProfileImageSize.square); } else { SA_StatusBar.text = "Opps, user data load failed, something was wrong"; Debug.Log("Opps, user data load failed, something was wrong"); } }
private void OnUserDataLoaded(FB_Result result) { SPFacebook.OnUserDataRequestCompleteAction -= OnUserDataLoaded; if (result.IsSucceeded) { SA_StatusBar.text = "User data loaded"; IsUserInfoLoaded = true; myInfo = SPFacebook.instance.userInfo; Debug.Log("Email = " + myInfo.Email); Debug.Log(myInfo.ProfileUrl); if (PostLogin != null) { PostLogin("OK"); } } else { OnUserDataLoadFailed(); } }
private void OnFriendsDataLoaded(FB_Result res) { SPFacebook.OnFriendsDataRequestCompleteAction -= OnFriendsDataLoaded; if (res.Error == null) { //friednds data available, we can get it using //SPFacebook.instance.friendsList getter //and we can also use FacebookUserInfo methods, for exmple download user avatar image foreach (FB_UserInfo friend in SPFacebook.Instance.friendsList) { friend.LoadProfileImage(FB_ProfileImageSize.square); } IsFrindsInfoLoaded = true; } else { Debug.Log("Opps, friends data load failed, something was wrong"); } }
private void OnScoreSubmited(FB_Result result) { if (result.IsFailed) { OnSubmitScoreRequestCompleteAction(result); return; } if (result.RawData.Equals("true")) { FB_Score score = new FB_Score(); score.AppId = AppId; score.UserId = UserId; score.value = lastSubmitedScore; if (_appScores.ContainsKey(UserId)) { _appScores[UserId].value = lastSubmitedScore; } else { _appScores.Add(score.UserId, score); } if (_userScores.ContainsKey(AppId)) { _userScores[AppId].value = lastSubmitedScore; } else { _userScores.Add(AppId, score); } } OnSubmitScoreRequestCompleteAction(result); }
private void OnFBAuth(FB_Result result) { SPFacebook.OnAuthCompleteAction -= OnFBAuth; if (SPFacebook.Instance.IsLoggedIn) { SPFacebook.instance.FB.FeedShare(_toId, _link, _linkName, _linkCaption, _linkDescription, _picture, _actionName, _actionLink, _reference); } else { FB_PostResult postResult = new FB_PostResult("", "Auth failed"); SPFacebook.Instance.PostCallback(postResult); } Destroy(gameObject); }
private void OnFBAuth(FB_Result result) { SPFacebook.OnAuthCompleteAction -= OnFBAuth; if(SPFacebook.Instance.IsLoggedIn) { SPFacebook.instance.FB.FeedShare(_toId, _link, _linkName, _linkCaption, _linkDescription, _picture, _actionName, _actionLink, _reference); } else { FB_PostResult postResult = new FB_PostResult("", "Auth failed"); SPFacebook.Instance.PostCallback(postResult); } Destroy(gameObject); }
private void OnRequestsLoadComplete(FB_Result result) { if (result.IsSucceeded) { Dictionary <string, object> JSON = ANMiniJSON.Json.Deserialize(result.RawData) as Dictionary <string, object>; List <object> data = JSON["data"] as List <object>; AppRequests.Clear(); foreach (object row in data) { FB_AppRequest request = new FB_AppRequest(); Dictionary <string, object> dataRow = row as Dictionary <string, object>; Dictionary <string, object> AppInfo = dataRow["application"] as Dictionary <string, object>; request.ApplicationId = System.Convert.ToString(AppInfo["id"]); if (!request.ApplicationId.Equals(AppId)) { break; } Dictionary <string, object> FromInfo = dataRow["from"] as Dictionary <string, object>; request.FromId = System.Convert.ToString(FromInfo["id"]); request.FromName = System.Convert.ToString(FromInfo["name"]); request.Id = System.Convert.ToString(dataRow["id"]); request.SetCreatedTime(System.Convert.ToString(dataRow["created_time"])); if (dataRow.ContainsKey("data")) { request.Data = System.Convert.ToString(dataRow["data"]); } if (dataRow.ContainsKey("message")) { request.Message = System.Convert.ToString(dataRow["message"]); } if (dataRow.ContainsKey("message")) { request.Message = System.Convert.ToString(dataRow["message"]); } if (dataRow.ContainsKey("action_type")) { string action_type = System.Convert.ToString(dataRow["action_type"]); switch (action_type) { case "send": request.ActionType = FB_RequestActionType.Send; break; case "askfor": request.ActionType = FB_RequestActionType.AskFor; break; case "turn": request.ActionType = FB_RequestActionType.Turn; break; } } if (dataRow.ContainsKey("object")) { FB_Object obj = new FB_Object(); Dictionary <string, object> objectData = dataRow["object"] as Dictionary <string, object>; obj.Id = System.Convert.ToString(objectData["id"]); obj.Title = System.Convert.ToString(objectData["id"]); obj.Type = System.Convert.ToString(objectData["id"]); obj.SetCreatedTime(System.Convert.ToString(objectData["created_time"])); if (objectData.ContainsKey("image")) { List <object> images = objectData["image"] as List <object>; Debug.Log(objectData["image"]); foreach (object img in images) { Dictionary <string, object> imgData = img as Dictionary <string, object>; obj.AddImageUrl(System.Convert.ToString(imgData["url"])); } } request.Object = obj; } AppRequests.Add(request); } Debug.Log("SPFacebook: " + AppRequests.Count + "App request Loaded"); } else { Debug.LogWarning("SPFacebook: App requests failed to load"); Debug.LogWarning(result.Error.ToString()); } OnAppRequestsLoaded(result); }
private void OnAuth(FB_Result result) { if(SPFacebook.instance.IsLoggedIn) { IsAuntificated = true; SA_StatusBar.text = "user Login -> true"; } else { Debug.Log("Failed to log in"); } }
void OnAppRequestsLoaded (FB_Result result) { if(result.IsSucceeded) { //Printing all pending request's id's foreach(FB_AppRequest request in SPFacebook.instance.AppRequests) { Debug.Log("--------------------------"); Debug.Log(request.Id); Debug.Log(request.Message); Debug.Log(request.ActionType); Debug.Log(request.State); Debug.Log(request.Data); Debug.Log("--------------------------"); } } SPFacebook.OnAppRequestsLoaded -= OnAppRequestsLoaded; }
void HandleOnRevokePermission (FB_Result result) { Debug.Log("[HandleOnRevokePermission] result.IsSucceeded: " + result.IsSucceeded + " Responce: " + result.RawData); }
private void OnUserLikesResult(FB_Result result) { ActionComplete(result, this); Destroy(gameObject); }
private void OnAppScoreRequestComplete(FB_Result result) { if(result.IsSucceeded) { string msg = "Loaded " + SPFacebook.instance.appScores.Count + " scores results" + "\n"; msg += "Current Player Score = " + SPFacebook.instance.GetScoreByUserId(SPFacebook.instance.UserId); SA_StatusBar.text = msg; } else { SA_StatusBar.text = result.RawData; } }
void HandleOnRevokePermission(FB_Result result) { Debug.Log("[HandleOnRevokePermission] result.IsSucceeded: " + result.IsSucceeded + " Responce: " + result.RawData); }
// -------------------------------------- // EVENTS // -------------------------------------- private void OnLikesLoaded(FB_Result result) { //The likes is loaded so now we can find out for sure if user is like our page bool IsLikes = SPFacebook.Instance.IsUserLikesPage(SPFacebook.instance.UserId, UNION_ASSETS_PAGE_ID); if(IsLikes) { SA_StatusBar.text ="Current user Likes union assets"; } else { SA_StatusBar.text ="Current user does not like union assets"; } }
private void OnUserDataLoaded(FB_Result result) { SPFacebook.OnUserDataRequestCompleteAction -= OnUserDataLoaded; if (result.IsSucceeded) { SA_StatusBar.text = "User data loaded"; IsUserInfoLoaded = true; //user data available, we can get info using //SPFacebook.instance.userInfo getter //and we can also use userInfo methods, for exmple download user avatar image SPFacebook.Instance.userInfo.LoadProfileImage(FB_ProfileImageSize.square); } else { SA_StatusBar.text ="Opps, user data load failed, something was wrong"; Debug.Log("Opps, user data load failed, something was wrong"); } }
private void OnFriendsDataLoaded(FB_Result res) { SPFacebook.OnFriendsDataRequestCompleteAction -= OnFriendsDataLoaded; if(res.Error == null) { //friednds data available, we can get it using //SPFacebook.instance.friendsList getter //and we can also use FacebookUserInfo methods, for exmple download user avatar image foreach(FB_UserInfo friend in SPFacebook.instance.friendsList) { friend.LoadProfileImage(FB_ProfileImageSize.square); } IsFrindsInfoLoaded = true; } else { Debug.Log("Opps, friends data load failed, something was wrong"); } }
private void PostCallback_Internal(FB_Result result) { FB_PostResult pr = new FB_PostResult(result.RawData, result.Error); OnPostingCompleteAction(pr); }
private void OnDeleteScoreRequestComplete(FB_Result result) { if(result.IsSucceeded) { string msg = "Score successfully deleted" + "\n"; msg += "Current Player Score = " + SPFacebook.instance.GetScoreByUserId(SPFacebook.instance.UserId); SA_StatusBar.text = msg; } else { SA_StatusBar.text = result.RawData; } }
//scores Api events private void OnPlayerScoreRequestComplete(FB_Result result) { if(result.IsSucceeded) { string msg = "Player has scores in " + SPFacebook.instance.userScores.Count + " apps" + "\n"; msg += "Current Player Score = " + SPFacebook.instance.GetCurrentPlayerIntScoreByAppId(SPFacebook.Instance.AppId); SA_StatusBar.text = msg; } else { SA_StatusBar.text = result.RawData; } }