Ejemplo n.º 1
0
        public JsonResult FbLogin(string JsonData)
        {
            var UserFbData = FacebookUtil.FetchingData(JsonData);

            PrepareUser(UserFbData);

            session.IsFbLogin = true;

            return(Json(new { result = "1" }, "text/plain"));
        }
Ejemplo n.º 2
0
    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"];
        }
    }
Ejemplo n.º 3
0
    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;
        });
    }
Ejemplo n.º 4
0
    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));
    }
Ejemplo n.º 5
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";
        }
    }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
        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"));
            }
        }
Ejemplo n.º 8
0
    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);
    }
Ejemplo n.º 9
0
    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"];
        }
    }
Ejemplo n.º 10
0
    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)); }
        //    });
        //}
    }
Ejemplo n.º 11
0
        public ActionResult Default()
        {
            ViewBag.IsPageLiked = FacebookUtil.IsPageLiked(Request.Params["signed_request"]);

            return(View());
        }
Ejemplo n.º 12
0
 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);
 }