public JsonResult FbLogin(string JsonData) { var UserFbData = FacebookUtil.FetchingData(JsonData); PrepareUser(UserFbData); session.IsFbLogin = true; return(Json(new { result = "1" }, "text/plain")); }
void OnUpdateRankingCallback(FBResult pResult) { List <object> scoresList = FacebookUtil.DeserializeScores(pResult.Text); foreach (object score in scoresList) { var entry = (Dictionary <string, object>)score; var user = (Dictionary <string, object>)entry["user"]; } }
public void GetProfilePicture(OnFacebookDelegate pPictureCallback) { onGetProfilePictureCallback += pPictureCallback; FB.API(FacebookUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, (FBResult result) => { if (onGetProfilePictureCallback != null) { onGetProfilePictureCallback(result); } onGetProfilePictureCallback = null; }); }
void HandleProfilePicture(FBResult result) { // Check for errors if (result.Error != null) { // If problem occur Debug.Log("Problem with getting the profile picture"); FB.API(FacebookUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, HandleProfilePicture); return; } Image UserAvatar = UIFBAvatar.GetComponent <Image>(); // Facebook will return a texture UserAvatar.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0)); }
void OnUpdateRankingCallback(FBResult pResult) { List <object> scoresList = FacebookUtil.DeserializeScores(pResult.Text); if (rankingText != null) { rankingText.text = string.Empty; } foreach (object score in scoresList) { var entry = (Dictionary <string, object>)score; var user = (Dictionary <string, object>)entry["user"]; rankingText.text += user["name"] + " : " + entry["score"] + "\n"; } }
void HandleFBMenus(bool isLoggedIn) { if (isLoggedIn) { UIFBIsLoggedIn.SetActive(true); UIFBIsNotLoggedIn.SetActive(false); // Get Profile picture FB.API(FacebookUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, HandleProfilePicture); // Get User Name FB.API("/me?fields=id,first_name,middle_name,last_name", Facebook.HttpMethod.GET, HandleUserName); } else { UIFBIsLoggedIn.SetActive(false); UIFBIsNotLoggedIn.SetActive(true); } }
public JsonResult FbLogin(string JsonData) { try { var UserFbData = FacebookUtil.FetchingData(JsonData); PrepareUser(UserFbData); session.IsFbLogin = true; return(Json(new { result = "1" }, "text/plain")); } catch (Exception ex) { return(Json(new { result = ex.Message + " inner ex: " + ex.InnerException }, "text/plain")); } }
void GetUserInfoCallback(FBResult result) { if (result.Error != null) { Debug.Log("Get username fail"); return; } Debug.Log("GetUserInfoCallback: " + result.Text); string[] fields = new string[] { "id", "name" }; Dictionary <string, string> playerProfile = FacebookUtil.DeserializeJSONProfile(result.Text, fields); // Set Player's avatar and name PlayerAvatar.SetActive(true); PlayerName.SetActive(true); Text username = PlayerName.GetComponent <Text>(); username.text = "Hello, " + playerProfile["name"]; userInfo.userID = string.Copy(playerProfile ["id"]); userInfo.userName = string.Copy(playerProfile ["name"]); List <object> friends = FacebookUtil.DeserializeJSONFriends(result.Text); userInfo.userFriends = ""; for (int i = 0; i < friends.Count; i++) { var friendDict = ((Dictionary <string, object>)(friends[i])); string friendID = (string)friendDict["id"]; userInfo.userFriends += friendID + "|"; } //Get avatar FB.API(FacebookUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, GetAvatarCallback); }
void HandleUserName(FBResult result) { // Check for errors if (result.Error != null) { // If problem occur Debug.Log("Problem with getting the user name"); FB.API("/me?fields=id,first_name,last_name", Facebook.HttpMethod.GET, HandleUserName); return; } profile = FacebookUtil.DeserializeJSONProfile(result.Text); Text UserMsg = UIFBUserName.GetComponent <Text>(); if (profile.Count == 2) { UserMsg.text = profile["first_name"] + " " + profile["last_name"]; } else { UserMsg.text = profile["first_name"] + " " + profile["middle_name"] + " " + profile["last_name"]; } }
private void ScoresCallback(FBResult result) { Debug.Log("Scores callback: " + result.Text); scoresList = FacebookUtil.DeserializeScores(result.Text); int a = 5; //foreach (Transform child in UIFBScoreList.transform) //{ // GameObject.Destroy(child.gameObject); //} //foreach (object score in scoresList) //{ // var entry = (Dictionary<string, object>)score; // var user = (Dictionary<string, object>)entry["user"]; // GameObject ScorePanel; // ScorePanel = Instantiate(UIFBScoreEntryPanel) as GameObject; // ScorePanel.transform.SetParent(UIFBScoreList.transform,false); // // Sets the transform for the three // Transform FriendName = ScorePanel.transform.Find("FriendName"); // Transform FriendScore = ScorePanel.transform.Find("FriendScore"); // Transform FriendAvatar = ScorePanel.transform.Find("FriendAvatar"); // Text FriendTextName = FriendName.GetComponent<Text>(); // Text FriendTextScore = FriendScore.GetComponent<Text>(); // Image FriendImageAvatar = FriendAvatar.GetComponent<Image>(); // FriendTextName.text = user["name"].ToString(); // FriendTextScore.text = entry["score"].ToString(); // // Gets the friends avatar + checks for errors before creating the sprite // FB.API(FacebookUtil.GetPictureURL(user["id"].ToString(), 128, 128), Facebook.HttpMethod.GET, delegate(FBResult pictureResult) // { // if (pictureResult.Error != null) // { // Debug.Log(pictureResult.Error); // } // else { FriendImageAvatar.sprite = Sprite.Create(pictureResult.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0)); } // }); //} }
public ActionResult Default() { ViewBag.IsPageLiked = FacebookUtil.IsPageLiked(Request.Params["signed_request"]); return(View()); }
public void SetProfilePicture() { FB.API(FacebookUtil.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, HandleProfilePicture); // Get User Name FB.API("/me?fields=id,first_name,middle_name,last_name", Facebook.HttpMethod.GET, HandleUserName); }