示例#1
0
    private void GetPicture(IGraphResult result)
    {
        //http://stackoverflow.com/questions/19756453/how-to-get-users-profile-picture-with-facebooks-unity-sdk
        if (result.Error == null && result.Texture != null)
        {
            gTexture = new Texture2D(0, 0);
            gTexture = result.Texture;
            UIManagerMenu.typeConnection = "facebook";

            /*
             * GameObject play = GameObject.Find ("ButtonLocal");
             * AudioSource click = play.GetComponent<AudioSource>();
             *
             * if (soundActive == true)
             * {
             *      click.Play ();
             * }
             * else
             * {
             *      if (click.isPlaying == true)
             *      {
             *              click.Stop();
             *      }
             * }*/

            GameObject imageLog      = GameObject.Find("ImageLogIn");
            Animator   imageLog_anim = imageLog.GetComponent <Animator> ();
            imageLog_anim.Play("LeaveLogin");

            SceneManager.LoadScene("Scenes/Map");
        }
    }
示例#2
0
    void FBFriendsCallback(IGraphResult result)
    {
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            // Let's just try again
            FB.API("/me?fields=id,name,friends.limit(100).fields(name,id)", Facebook.Unity.HttpMethod.GET, FBFriendsCallback);
            return;
        }
        Data.Instance.userData.ResetFacebookFriends();

        var         data    = Facebook.MiniJSON.Json.Deserialize(result.RawResult) as Dictionary <string, object>;
        IDictionary dict    = Facebook.MiniJSON.Json.Deserialize(result.RawResult) as IDictionary;
        var         friends = dict["friends"] as Dictionary <string, object>;

        System.Collections.Generic.List <object> ff = friends["data"] as System.Collections.Generic.List <object>;

        foreach (var obj in ff)
        {
            Dictionary <string, object> facebookFriendData = obj as Dictionary <string, object>;
            Data.Instance.userData.AddFacebookFriend(facebookFriendData["id"].ToString(), facebookFriendData["name"].ToString());
        }

        Events.OnFacebookFriends();
    }
示例#3
0
 // search?q={0}&type=user&fields=picture, where {0} is searched string
 private void OnFB_GetSearchPictures( IGraphResult result )
 {
     Debug.Log( result );
     var data = result.ResultDictionary.GetValueOrDefault<List<object>>( "data" );
     if( data != null )
     {
         var pictureUrls = new List<String>();
         foreach( var entry in data )
         {
             var entryData = entry as Dictionary<string, object>;
             if( entryData != null )
             {
                 var pictureData = entryData["picture"] as Dictionary<string, object>;
                 if( pictureData != null )
                 {
                     var urlData = pictureData["data"] as Dictionary<string, object>;
                     if( urlData != null )
                     {
                         string pictureUrl = (string)urlData["url"];
                         pictureUrls.Add( pictureUrl );
                     }
                 }
             }
         }
         StartCoroutine( OnWWW_GetPictures( pictureUrls ) );
     }
 }
 void AddFriendPicture(IGraphResult result)
 {
     if (result.Error == null && result.Texture != null)
     {
         friendPicture = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), Vector2.zero);
     }
 }
示例#5
0
    private void PlayerGetFriendsRankingCallback(IGraphResult result)
    {
        UnityEngine.Debug.Log(result.RawResult);
        friendsIdList = new List <string>();
        Dictionary <string, object> dictionary = (Dictionary <string, object>)result.ResultDictionary;

        if (dictionary.ContainsKey("data"))
        {
            foreach (Dictionary <string, object> item in (List <object>)dictionary["data"])
            {
                if (item.ContainsKey("id"))
                {
                    string text = (string)item["id"];
                    friendsIdList.Add(text);
                    UnityEngine.Debug.Log(text);
                }
            }
            if (friendsIdList.Count > 0)
            {
                friendsIdList.Add((string)FBUserDetails["id"]);
                StartCoroutine(PlayerGetFriendsRankingOurService(friendsIdList));
            }
            else
            {
                ReportRankingResult(null, FBRankingState.DONE);
            }
        }
        else
        {
            ReportRankingResult("", FBRankingState.ERROR);
        }
    }
示例#6
0
 void OnGetUserDetailsComplete(IGraphResult result)
 {
     if (OnGetUserDetails != null)
     {
         OnGetUserDetails(DeserializeFBResult(result.RawResult));
     }
 }
示例#7
0
 private void setAvatar(IGraphResult result)
 {
     if (result.Texture != null)
     {
         AvatarImage.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2());
     }
 }
示例#8
0
    private void DeleteCallback(IGraphResult result)
    {
        if (!string.IsNullOrEmpty(result.RawResult))
        {
            Debug.Log(result.RawResult);

            var resultDictionary = result.ResultDictionary;
            if (resultDictionary.ContainsKey("data"))
            {
                var dataArray = (List <object>)resultDictionary["data"];

                if (dataArray.Count > 0)
                {
                    for (int i = 0; i < dataArray.Count; i++)
                    {
                        var firstGroup = (Dictionary <string, object>)dataArray[i];
                        FB.API((string)firstGroup["id"], HttpMethod.DELETE, APICallBack);
                    }
                    //this.gamerGroupCurrentGroup = (string)firstGroup["id"];
                }
            }
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            Debug.Log(result.Error);
        }
    }
示例#9
0
    void GotMyInformationCallback(IGraphResult result)
    {
        print(result.RawResult);
        if (result.Error != null)
        {
            print(result.Error);
        }
        else
        {
            profile = JsonUtility.FromJson <MyFacebookInfo>(result.RawResult);

            /*
             * FB.API("/me?fields=email", HttpMethod.GET, graphResult =>
             *      {
             *              if (string.IsNullOrEmpty(graphResult.Error) == false)
             *              {
             *                      Debug.Log("could not get email address");
             *                      return;
             *              }
             *
             *              profile.email = graphResult.ResultDictionary["email"] as string;
             *              DebugLog (profile.email);
             *      });
             *
             */
            //StartCoroutine (LoadImage (profile.picture.data.url));
            //Login (profile.id);
            SigninWithFB(AccessToken.CurrentAccessToken.TokenString);
        }
    }
示例#10
0
    private void RequestCallback(IGraphResult result)
    {
        if (!string.IsNullOrEmpty(result.RawResult))
        {
            Debug.Log(result.RawResult);

            var resultDictionary = result.ResultDictionary;
            if (resultDictionary.ContainsKey("data"))
            {
                var dataArray = (List <object>)resultDictionary["data"];

                if (dataArray.Count > 0)
                {
                    for (int i = 0; i < dataArray.Count; i++)
                    {
                        var firstGroup = (Dictionary <string, object>)dataArray[i];
                        foreach (KeyValuePair <string, object> entry in firstGroup)
                        {
                            print(entry.Key + " " + entry.Value);
                        }
                        //print(firstGroup["id"] + " " + firstGroup["title"]);
                    }
                    //this.gamerGroupCurrentGroup = (string)firstGroup["id"];
                }
            }
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            Debug.Log(result.Error);
        }
    }
示例#11
0
 private void GetPicture(IGraphResult result)
 {
     if (result.Texture != null)
     {
         ProfilePic = result.Texture;
     }
 }
示例#12
0
        /// <summary>
        /// Gets (from Facebook API) and sets (in to CurrentUser) info about the user
        /// (i.e Name and FB User ID) from a Facebook API call
        /// </summary>
        /// <param name="callbackResult">Result of a FB API Call for ("/me")</param>
        private static void UserInfoCallback(IGraphResult callbackResult)
        {
            //Create a dictonary of the result that we got back from the API Call
            Dictionary <string, object> callbackResultsDictionary =
                (Dictionary <string, object>)Facebook.MiniJSON.Json.Deserialize(callbackResult.RawResult);

            //Check that we have got the right call back (i.e it contains a key for name and user ID)
            if (!callbackResultsDictionary.ContainsKey("name") || !callbackResultsDictionary.ContainsKey("id"))
            {
                Debug.LogWarning("UserInfoCallback was called with the wrong call back info");

                //Trigger Event for unsuccessful login and log out the current user
                FBLoginEvent?.Invoke(LoginEventResult.LoginFailed);
                FacebookLogout();
                return;
            }

            //We get the name and userID back from our API call. (Name: "", userID: "")
            //we need to put this in our user info class
            CurrentUser = new FBUserInfo((string)callbackResultsDictionary["name"],
                                         Convert.ToInt64(callbackResultsDictionary["id"]));

            //Trigger event for successful logon
            FBLoginEvent?.Invoke(LoginEventResult.LoginSuccess);
        }
示例#13
0
 private void CallbackShareImage(IGraphResult result)
 {
     if (result.Error != null)
         Debug.Log ("FB ERROR to share image " + result.Error);
     else
         Debug.Log ("SHARE image SUCESS");
 }
示例#14
0
        //callback of from Facebook API when the leaderboard data from the server is loaded.
        void CallBackLoadLeaderboard(IGraphResult result)
        {
            if (string.IsNullOrEmpty(result.Error) && !result.Cancelled)
            {
                //Dictionary<string, object> JSON = Json.Deserialize(result.RawResult) as Dictionary<string, object>;

                List <object> data = result.ResultDictionary["data"] as List <object>;              //JSON["data"] as List<object>;
                for (int i = 0; i < data.Count; i++)
                {
                    string fScore;
                    try
                    {
                        fScore = Convert.ToString(((Dictionary <string, object>)data[i])["score"]);
                    }
                    catch (Exception)
                    {
                        fScore = "0";
                    }
                    Dictionary <string, object> UserInfo = ((Dictionary <string, object>)data[i])["user"] as Dictionary <string, object>;
                    string name = Convert.ToString(UserInfo["name"]);
                    string id   = Convert.ToString(UserInfo["id"]);
                    CreateListItemLeaderboard(id, name, fScore, i + 1);
                    LoadFriendsAvatar(i);
                }
            }

            ShowHideLoader(1, false);
            print(result.RawResult);
            inpLeadSearcher.text = "";
        }
示例#15
0
    private void RequestFriendsCallback(IGraphResult result)
    {
        if (!string.IsNullOrEmpty(result.RawResult))
        {
            //			Debug.Log (result.RawResult);

            var resultDictionary = result.ResultDictionary;
            if (resultDictionary.ContainsKey("data"))
            {
                var dataArray = (List <object>)resultDictionary["data"];               //2.1.4
                var dic       = dataArray.Select(x => x as Dictionary <string, object>).ToArray();

                foreach (var item in dic)
                {
                    string     id     = (string)item["id"];
                    var        url    = item.Where(x => x.Key == "picture").SelectMany(x => x.Value as Dictionary <string, object>).Where(x => x.Key == "data").SelectMany(x => x.Value as Dictionary <string, object>).Where(i => i.Key == "url").First().Value;
                    FriendData friend = Friends.Where(x => x.FacebookID == id).FirstOrDefault();
                    if (friend != null)
                    {
                        GetPictureByURL("" + url, friend);
                    }
                }
            }


            if (!string.IsNullOrEmpty(result.Error))
            {
                Debug.Log(result.Error);
            }
        }
    }
示例#16
0
 private void OnGetSelfData(IGraphResult result)
 {
     this.HaveSelfData = true;
     if (result != null && !string.IsNullOrEmpty(result.RawResult))
     {
         object obj = new JsonParser(result.RawResult).Parse();
         Dictionary <string, object> dictionary = obj as Dictionary <string, object>;
         if (dictionary.ContainsKey("gender"))
         {
             this.Gender = (string)dictionary["gender"];
         }
         if (dictionary.ContainsKey("name"))
         {
             this.FullName = (string)dictionary["name"];
         }
         if (dictionary.ContainsKey("locale"))
         {
             this.FacebookLocale = (string)dictionary["locale"];
         }
         if (dictionary.ContainsKey("first_name"))
         {
             this.FirstName = (string)dictionary["first_name"];
         }
         if (dictionary.ContainsKey("last_name"))
         {
             this.LastName = (string)dictionary["last_name"];
         }
         if (dictionary.ContainsKey("id"))
         {
             this.FacebookId = (string)dictionary["id"];
         }
     }
     this.DoCallbacksIfHaveAllData();
 }
示例#17
0
 private void DisplayUsersPic(IGraphResult results)
 {
     if (results.Texture != null)
     {
         if (DataManager.Instance.GetUserId() != Construct._USERID && DataManager.Instance.GetUserId() != Construct._USERNAME && DataManager.Instance.GetUserId() != Construct._USERACCESSTOKEN)
         {
             string userPicture = "https://graph.facebook.com/" + DataManager.Instance.GetUserId() + "/picture?width=200";
             DataManager.Instance.new2dpicture(DataManager.Instance.UserImagePic, userPicture);
             DataManager.Instance.SetUserPic(userPicture);
             DataManager.Instance.SetUserName(DataManager.Instance.GetUserFirstName() + " " + DataManager.Instance.GetUserLastName());
             DataManager.Instance.SetUserActivation(Construct._ONE);
             ServerStatusManager.Instance.SendNewDataType(Construct.ONLOGIN);
             WelcomeMessage.text = "Welcome, " + DataManager.Instance.GetUserFirstName() + " To " + SystemConfig.Instance.AppName;
         }
         else
         {
             Debug.Log("THE PICTURE IS NOT WHAT IT SHOULD BE");
         }
     }
     else
     {
         //we had a picture error
         Debug.Log("THE PICTURE IS NOT WHAT IT SHOULD BE WE HAVE SOME ERROR FROM FACEBOOK");
     }
 }
    private void GetUserNameCallback(IGraphResult result)
    {
        if (result == null)
        {
            AN_PoupsProxy.ShowToast("GetUserName null");
        }

        // Some platforms return the empty string instead of null.
        if (!string.IsNullOrEmpty(result.Error))
        {
            AN_PoupsProxy.ShowToast("GetUserName Error " + result.Error);
        }
        else if (result.Cancelled)
        {
            AN_PoupsProxy.ShowToast("GetUserName Cancelled");
        }
        else if (result.ResultList != null && result.ResultList.Count > 0)
        {
            AN_PoupsProxy.ShowToast("GetUserName Success " + result.ResultList.Count + " " + result.ResultList[0].ToString());
        }
        else
        {
            AN_PoupsProxy.ShowToast("GetUserName Success ResultList IsNullOrEmpty");
        }
    }
示例#19
0
        protected virtual void FacebookData(IGraphResult result)
        {
            if (result.Error != null)
            {
                return;
            }

            if (result.ResultDictionary.ContainsKey("name"))
            {
                fbName = result.ResultDictionary["name"].ToString();
                fbDataDic["FB Name"] = fbName;
            }

            if (result.ResultDictionary.ContainsKey("email"))
            {
                fbEmail            = result.ResultDictionary["email"].ToString();
                fbDataDic["Email"] = fbEmail;
            }

            if (result.ResultDictionary.ContainsKey("id"))
            {
                fbId = result.ResultDictionary["id"].ToString();
                fbDataDic["FB ID"] = fbId;
            }

            if (result.ResultDictionary.ContainsKey("picture"))
            {
                fbAvatarURL = ((Dictionary <string, object>)((Dictionary <string, object>)result.ResultDictionary[
                                                                 "picture"])["data"])["url"].ToString();
            }
        }
示例#20
0
 // More universal callback function, which works on mostly of the processes.
 // Does not work with the link sharing and score sharing.
 private void FacebookProcessCallBack(IGraphResult resultas)
 {
     if (!string.IsNullOrEmpty(resultas.RawResult)) // Success
     {
         if (CurrentFacebookProcess == "UserPhoto")
         {
             Cus.LogAMessage("[Facebook SDK]: Successfully got the UserPhoto!\n");
             StatsM.CurrentUserFacebookFriendsPhotos.Add(resultas.Texture);
             StatsM.FacebookPhotoIndex++;
         }
         else if (CurrentFacebookProcess == "GetFBScoreBoard")
         {
             Cus.LogAMessage("[Facebook SDK]: Successfully read the ScoreBoard!");
             StatsM.ReadPlayerFBStatistics(resultas);
         }
     }
     else
     {
         if (CurrentFacebookProcess == "UserPhoto")
         {
             Cus.LogAMessage("[Facebook SDK]: Failed to get UserPhoto, because: \n" + resultas.Error);
             StatsM.FacebookPhotoIndex++;
         }
         else if (CurrentFacebookProcess == "GetFBScoreBoard")
         {
             Cus.LogAMessage("[Facebook SDK]: Failed to get Score data from FB, because: \n" + resultas.Error);
             ErrorM.ShowErrorArea("Nepavyko nuskaityti duomenų iš " + Environment.NewLine + "Facebook serverių!", -1);
         }
     }
 }
示例#21
0
 public void GetMyScore(IGraphResult result)
 {
     //Debug.Log ("Get My Score : " + result.RawResult);
     if (FBErrorEvent != null)
     {
         FBErrorEvent(result.RawResult);
     }
     if (result.Error == null)
     {
         canSaveScore = true;
         IDictionary <string, object> data = result.ResultDictionary;
         List <object> scorelist           = (List <object>)data ["data"];
         foreach (object obj in scorelist)
         {
             var entry = (Dictionary <string, object>)obj;
             //var user = (Dictionary<string, object>)entry ["user"];
             //Debug.Log (user ["name"].ToString () + " , " + entry ["score"]);
             if (!Int32.TryParse(entry ["score"].ToString(), out profileScore))
             {
                 Debug.Log("try parse on score entry failed");
             }
             //Debug.Log ("profile score = " + profileScore);
         }
     }
     else
     {
         canSaveScore = false;
         if (FBErrorEvent != null)
         {
             FBErrorEvent("Error triggered on my score : " + result.Error);
         }
     }
 }
示例#22
0
 //callback of from Facebook API when the leaderboard data from the server is loaded.
 void CallBackLoadLeaderboard(IGraphResult result)
 {
     if (string.IsNullOrEmpty(result.Error) && !result.Cancelled)
     {
         Dictionary <string, object> JSON = Json.Deserialize(result.RawResult) as Dictionary <string, object>;
         List <object> data = JSON["data"] as List <object>;
         for (int i = 0; i < data.Count; i++)
         {
             string fScore;
             try
             {
                 fScore = Convert.ToString(((Dictionary <string, object>)data[i])["score"]);
             }
             catch (Exception)
             {
                 fScore = "0";
             }
             Dictionary <string, object> UserInfo = ((Dictionary <string, object>)data[i])["user"] as Dictionary <string, object>;
             string name = Convert.ToString(UserInfo["name"]);
             string id   = Convert.ToString(UserInfo["id"]);
             CreateListItemLeaderboard(id, name, fScore, i + 1);
             LoadFriendsAvatar(i);
         }
         leaderboardLoading.SetActive(false);
     }
     if (result.Error != null)
     {
         FB.API(getScoreAPIString, HttpMethod.GET, CallBackLoadLeaderboard);
         return;
     }
 }
示例#23
0
        private void OnProfilePhotoCallback(IGraphResult result)
        {
            if (string.IsNullOrEmpty(result.Error) && result.Texture != null)
            {
                m_Asset = result.Texture;

                try
                {
                    if (File.Exists(localResPath))
                    {
                        File.Delete(localResPath);
                    }
                    byte[] bytes = result.Texture.EncodeToJPG();
                    File.WriteAllBytes(localResPath, bytes);
                }
                catch (Exception e)
                {
                    Log.e(e);
                    //如果保存出错,删除出错文件
                    if (File.Exists(localResPath))
                    {
                        File.Delete(localResPath);
                    }
                }

                resState = eResState.kReady;
            }
            else
            {
                OnResLoadFaild();
            }
        }
示例#24
0
 private void OnGetFriendsData(IGraphResult result)
 {
     this.Friends = new List <SocialFriendData>();
     this.PlayerIdToFriendData = new Dictionary <string, SocialFriendData>();
     this.InstalledFBIDs       = new List <string>();
     if (!string.IsNullOrEmpty(result.RawResult))
     {
         object obj = new JsonParser(result.RawResult).Parse();
         Dictionary <string, object> dictionary = obj as Dictionary <string, object>;
         List <object> list = dictionary["data"] as List <object>;
         for (int i = 0; i < list.Count; i++)
         {
             SocialFriendData socialFriendData = (SocialFriendData) new SocialFriendData().FromObject(list[i]);
             this.Friends.Add(socialFriendData);
             if (socialFriendData.Installed)
             {
                 this.InstalledFBIDs.Add(socialFriendData.Id);
             }
         }
         this.CommonFriendDataActions();
     }
     else
     {
         Service.Logger.ErrorFormat("Error fetching FB friends data: {0}", new object[]
         {
             result.Error
         });
     }
 }
示例#25
0
    void NameCallBack(IGraphResult result)
    {
        Debug.Log(result.RawResult);
        IDictionary <string, object> profile = result.ResultDictionary;

        LoggedInUI.transform.FindChild("Name").GetComponent <Text>().text = "Hello " + profile ["first_name"];
    }
示例#26
0
 void DisplayProfilePic(IGraphResult result)
 {
     if (result.Texture != null)
     {
         ProfilePic = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2());
     }
 }
示例#27
0
    private void PostsCallback(IGraphResult result)
    {
        if (result.Error == null)
        {
            Debug.Log("Result: " + result.RawResult);

            FBGraphResult graphObject = FBGraphResult.CreateFromJSON(result.RawResult);
            if (graphObject != null)
            {
                Debug.Log("Created a graphObject");
                Debug.Log("num posts: " + graphObject.data.Count);
                for (int i = 0; i < 3; i++)
                {
                    Debug.Log("id: " + graphObject.data[i].id + ", message: " +
                              graphObject.data[i].message + " full pic: " +
                              graphObject.data[i].full_picture + " pic: " +
                              graphObject.data[i].picture);

                    if (graphObject.data[i].picture != "")
                    {
                        IEnumerator coroutine = DownloadFBImage(graphObject.data[i].picture);
                        StartCoroutine(coroutine);
                    }
                }
            }
        }

        FB.LogOut();
    }
示例#28
0
 private void GetPicture(IGraphResult result)
 {
     if (result.Error == null && result.Texture != null)
     {
         ProfilePicture.sprite = Sprite.Create(result.Texture, new Rect(0, 0, 128, 128), new Vector2());
     }
 }
示例#29
0
 void OnImageUploaded(IGraphResult result)
 {
     if (OnImageUpload != null)
     {
         OnImageUpload(DeserializeFBResult(result.RawResult));
     }
 }
示例#30
0
    private void NameCallBack(IGraphResult result)
    {
        string userName = (string)result.ResultDictionary["name"];

        print(userName + "님 안녕하세요^^");
        PlayerPrefs.SetString("nickName", userName);
    }
示例#31
0
    private static void GetPlayerInfoCallback(IGraphResult result)
    {
        Debug.Log("GetPlayerInfoCallback");
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }
        Debug.Log(result.RawResult);

        // Save player name
        string name;
        if (result.ResultDictionary.TryGetValue("first_name", out name))
        {
            GameStateManager.Username = name;
        }

        //Fetch player profile picture from the URL returned
        string playerImgUrl = GraphUtil.DeserializePictureURL(result.ResultDictionary);
        GraphUtil.LoadImgFromURL(playerImgUrl, delegate(Texture pictureTexture)
        {
            // Setup the User's profile picture
            if (pictureTexture != null)
            {
                GameStateManager.UserTexture = pictureTexture;
            }

            // Redraw the UI
            GameStateManager.CallUIRedraw();
        });

    }
示例#32
0
    private void FetchProfileCallbackFB(IGraphResult result)
    {
        //uiLogin.Hide ();
        Logger.E("FB: " + result.RawResult);
        FBUserDetails = (Dictionary <string, object>)result.ResultDictionary;
        Dictionary <string, object> pictureDetails = (Dictionary <string, object>)FBUserDetails["picture"];
        Dictionary <string, object> pictureData    = (Dictionary <string, object>)pictureDetails["data"];

        string fb_id    = FBUserDetails["id"].ToString();
        string fb_email = string.Empty;

        if (FBUserDetails.ContainsKey("email"))
        {
            fb_email = FBUserDetails["email"].ToString();
        }
        else
        {
            string deviceID      = SystemInfo.deviceUniqueIdentifier;
            string cleanDeviceID = RemoveSpecialCharacters(deviceID);
            if (cleanDeviceID.Length > 50)
            {
                cleanDeviceID = cleanDeviceID.Substring(0, 50);
            }

            fb_email = cleanDeviceID + "@empty.fb";
        }

        string fb_name = FBUserDetails["name"].ToString();
        string fb_url  = "https://graph.facebook.com/{0}/picture?type=normal";

        fb_url = string.Format(fb_url, fb_id);
        ApiManager.instance.FacebookLogin(fb_id, fb_email, fb_name, fb_url);
    }
示例#33
0
 void Callback(IGraphResult result)
 {
     if (result.Error != null)
     {
         return;
     }
 }
示例#34
0
 void FriendCallBack(IGraphResult result)
 {
     IDictionary<string, object> data = result.ResultDictionary;
     List<object> friends = (List<object>)data ["data"];
     foreach (object obj in friends) {
         Dictionary<string, object> dictio = (Dictionary<string, object>)obj;
         CreateFriend(dictio ["name"].ToString (), dictio ["id"].ToString ());
     }
 }
        private void ProfilePhotoCallback(IGraphResult result)
        {
            if (string.IsNullOrEmpty(result.Error) && result.Texture != null)
            {
                this.profilePic = result.Texture;
            }

            this.HandleResult(result);
        }
示例#36
0
    public void ReturnUserCallback(IGraphResult result)
    {
        var dict = Json.Deserialize(result.RawResult) as Dictionary<string,object>;

        PlayerPrefs.SetString ("fbId", dict ["id"].ToString() );
        PlayerPrefs.SetString ("fbName", dict ["name"].ToString() );
        PlayerPrefs.SetInt ("fbLogged", 1 );

        updatePhoto ();
    }
示例#37
0
	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);
	}
示例#38
0
	private void OnPostSuccess(IGraphResult result)
	{
		if (!string.IsNullOrEmpty(result.Error)) 
		{
			Debug.LogError("Post error: " + result.Error);
		}
		else
		{
			Debug.Log("Post successful!");
		}
	}
 void CallbackShareImage(IGraphResult result)
 {
     if(result.Error != null)
     {
         Debug.Log("********** FB error at share Image " + result.Error);
     }
     else
     {
         Debug.Log("********** FB share Image sucess");
     }
 }
示例#40
0
 void OnGetFriendsList(IGraphResult result)
 {
     List<object> l = (List<object>)result.ResultDictionary["data"];
     posts.Clear();
     for (int i = 0; i < l.Count; i++) 
     {
         posts.Add(new PopularityDataModel.FBPostModel((Dictionary<string, object>) l[i]));
     }
     posts.Sort((x, y) => y.totalLikes.CompareTo(x.totalLikes));
     FBUIInstance.GetComponent<FBProgressPanel>().SetupProgressPanels(posts);
 }
    public void UserIdCallBack(IGraphResult result)
    {
        // Set User name
        levelManager.mUserName = (string)result.ResultDictionary["name"];
        levelManager.mUserId = (string)result.ResultDictionary["id"];
        Debug.Log("User name is " + levelManager.mUserName);
        Debug.Log("User id is " + levelManager.mUserId);

        // Link FB account with Shephertz
        string token = AccessToken.CurrentAccessToken.TokenString;
        levelManager.socialService.LinkUserFacebookAccount(levelManager.mUserName, token, new ShephertzCallBack());
    }
示例#42
0
    void FBFriendsCallback(IGraphResult result)
    {
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            // Let's just try again
            FB.API("/me?fields=id,name,friends.limit(100).fields(name,id)", Facebook.Unity.HttpMethod.GET, FBFriendsCallback);
            return;
        }

        var data = Facebook.MiniJSON.Json.Deserialize(result.RawResult) as Dictionary<string, object>;
        IDictionary dict = Facebook.MiniJSON.Json.Deserialize(result.RawResult) as IDictionary;
        var friends = dict["friends"] as Dictionary<string, object>;
        System.Collections.Generic.List<object> ff = friends["data"] as System.Collections.Generic.List<object>;

        foreach (var obj in ff)
        {
            Dictionary<string, object> facebookFriendData = obj as Dictionary<string, object>;
            SocialEvents.AddFacebookFriend(facebookFriendData["id"].ToString(), facebookFriendData["name"].ToString());
        }
        print("OnFacebookFriends");
        SocialEvents.OnFacebookFriends();
    }
	public void handleFriendIds(IGraphResult result)
	{

		var dict = Json.Deserialize(result.RawResult) as Dictionary<string,object>;


		object friendsH;
		var friends = new List<object>();
		if(dict.TryGetValue ("friends", out friendsH)) {
			friends = (List<object>)(((Dictionary<string, object>)friendsH) ["data"]);

			for (int i = 0; i < 6; i++) {
				var friendDict = ((Dictionary<string,object>)(friends[i]));
				var friend = new Dictionary<string, string>();
				friend["id"] = (string)friendDict["id"];
				friend["first_name"] = (string)friendDict["first_name"];

				Debug.Log (friend ["id"] + friend ["first_name"]);

				FB.API( friend["id"] + "/picture?type=square&height=128&width=128", HttpMethod.GET, GetPictureCallBack);
			}
		}
	}
示例#44
0
        private void GetAllGroupsCB(IGraphResult result)
        {
            if (!string.IsNullOrEmpty(result.RawResult))
            {
                this.LastResponse = result.RawResult;
                var resultDictionary = result.ResultDictionary;
                if (resultDictionary.ContainsKey("data"))
                {
                    var dataArray = (List<object>)resultDictionary["data"];

                    if (dataArray.Count > 0)
                    {
                        var firstGroup = (Dictionary<string, object>)dataArray[0];
                        this.gamerGroupCurrentGroup = (string)firstGroup["id"];
                    }
                }
            }

            if (!string.IsNullOrEmpty(result.Error))
            {
                this.LastResponse = result.Error;
            }
        }
 private void ScoreCallBack(IGraphResult result)
 {
 }
	/*
	 * getpicturecallback
	 */
	public void GetPictureCallBack(IGraphResult result)
	{
		//set the texture to the wheel
		GameObject.Find("Manager").GetComponent<Manager>().AddWheelsTexture(result.Texture);
	}
示例#47
0
 void NameCallBack(IGraphResult result)
 {
     IDictionary<string, object> profile = result.ResultDictionary;
     LoggedInUI.transform.FindChild ("Name").GetComponent<Text> ().text = "Hello " + profile ["first_name"];
 }
        void PostCallback (IGraphResult result)
        {
            DebugUtils.DebugLog("PostCallback called.");
            if (result.Error != null)
            {
                DebugUtils.DebugLogError(result.Error);
                OnEventNotify(SNResultCode.kPostFailed);
                return;
            }

            DebugUtils.Log("Post successful!");
            OnEventNotify(SNResultCode.kPosted);
        }
示例#49
0
    void DealWithProfilePicture(IGraphResult result)
    {
        if (result.Error != null)
        {
            Debug.Log("problem with getting profile picture");
            FB.API("/me/picture", HttpMethod.GET, DealWithProfilePicture);
            return;
        }

        Image UserAvatar = UIFBAvatar.GetComponent<Image>();
        UserAvatar.sprite = Sprite.Create(result.Texture, new Rect(0, 0, result.Texture.width, result.Texture.height), new Vector2(0.5f, 0.5f));
        UserPhoto.GetComponent<Image>().sprite = Sprite.Create(result.Texture, new Rect(0, 0, result.Texture.width, result.Texture.height), new Vector2(0.5f, 0.5f));
    }
		/** Login Callbacks **/
		
		private void ProfileCallback(IGraphResult result) {
		}
示例#51
0
 void PictureCallBack(IGraphResult result)
 {
     Texture2D image = result.Texture;
     LoggedInUI.transform.FindChild ("ProfilePicture").GetComponent<Image> ().sprite = Sprite.Create (image, new Rect (0, 0, 100, 100), new Vector2 (0.5f, 0.5f));
 }
示例#52
0
    private static void GetInvitableFriendsCallback(IGraphResult result)
    {
        Debug.Log("GetInvitableFriendsCallback");
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }
        Debug.Log(result.RawResult);

        // Store /me/invitable_friends result
        object dataList;
        if (result.ResultDictionary.TryGetValue("data", out dataList))
        {
            var invitableFriendsList = (List<object>)dataList;
            CacheFriends(invitableFriendsList);
        }
    }
示例#53
0
    private static void GetScoresCallback(IGraphResult result) 
    {
        Debug.Log("GetScoresCallback");
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }
        Debug.Log(result.RawResult);

        // Parse scores info
        var scoresList = new List<object>();

        object scoresh;
        if (result.ResultDictionary.TryGetValue ("data", out scoresh)) 
        {
            scoresList = (List<object>) scoresh;
        }

        // Parse score data
        HandleScoresData (scoresList);

        // Redraw the UI
        GameStateManager.CallUIRedraw();
    }
	private void UpdateSurvivorDraftWindow (IGraphResult result) {
		if (result.Error == null) {
			//store the data object for later use in next friend being updated.
			fbFriendsResult = result;
			Debug.Log(result.ToString());
			string data = result.RawResult as string;
			Debug.Log(data);
			JsonData jsonData = JsonMapper.ToJson(data);

			//fill the player data into the play card objects on the draft window.
			for (int i=0; i<3; i++) {
				//set the name from the result.
				survivorDraftCardArray[i].survivor.name = jsonData[i]["name"].ToString();
				// roll and load random stats
				int stam = Random.Range(90, 140);
				survivorDraftCardArray[i].survivor.baseStamina = stam;
				survivorDraftCardArray[i].survivor.curStamina = stam;
				int attk = Random.Range(9, 25);
				survivorDraftCardArray[i].survivor.baseAttack = attk;

				//get and update the photo
				Image survivorPic = survivorDraftCardArray[i].profilePic;
				string imgUrl = jsonData[i]["picture"]["data"]["url"].ToString();
				WWW www = new WWW(imgUrl);
				survivorPic.sprite = Sprite.Create(www.texture, new Rect(0,0,200,200), new Vector2());

				//update the text field.
				string myText = "";
				myText += "name: " + survivorDraftCardArray[i].survivor.name.ToString()+"\n";
				myText += "stamina: " + survivorDraftCardArray[i].survivor.baseStamina.ToString()+"\n";
				myText += "attack: " +survivorDraftCardArray[i].survivor.baseAttack.ToString(); 
				survivorDraftCardArray[i].displayText.text = myText;
			}
		}else{
			Debug.Log(result.Error);
		}
	}
 void APICallback(IGraphResult result)
 {
     Debug.Log("APICallBack");
     Debug.Log(result);
 }
示例#56
0
    private void ScoresCallback(IGraphResult result)
    {
        Debug.Log("Scores callback: " + result.RawResult);

        scoreList = Util.DeserializeScores(result.RawResult);

        foreach(Transform child in ScoreScrolList.transform)
        {
            GameObject.Destroy(child.gameObject);
        }

        foreach (object score in scoreList)
        {
            var entry = (Dictionary<string, object>) score;
            var user = (Dictionary<string, object>) entry["user"];
            //scoresDebug.text = scoresDebug.text + "UN: " + user["name"] + " - " + entry["score"] + ", ";

            GameObject ScorePanel;
            ScorePanel = Instantiate(ScoreEntryPanel) as GameObject;
            ScorePanel.transform.parent = ScoreScrolList.transform;
            Transform ThisScoreName = ScorePanel.transform.Find("FriendName");
            Transform ThisScoreScore = ScorePanel.transform.Find("FriendScore");
            Text ScoreName = ThisScoreName.GetComponent<Text>();
            Text ScoreScore = ThisScoreScore.GetComponent<Text>();

            ScoreName.text = user["name"].ToString();
            ScoreScore.text = entry["score"].ToString();

            Transform TheUserAvatar = ScorePanel.transform.Find("FriendAvatar");
            Image UserAvatar = TheUserAvatar.GetComponent<Image>();

            FB.API(user["id"].ToString() + "/picture", HttpMethod.GET, delegate(IGraphResult pictureresult) {
                if(pictureresult.Error != null)
                {
                    Debug.Log(pictureresult.Error);
                }
                else
                {
                    UserAvatar.sprite = Sprite.Create(pictureresult.Texture, new Rect(0, 0, pictureresult.Texture.width, pictureresult.Texture.height), new Vector2(0.5f, 0.5f));
                }
            });
        }
    }
        void OnMyProfileCb (IGraphResult result)
        {
            DebugUtils.DebugLog("OnMyProfileCb called.");
            if (result.Error != null)
            {
                DebugUtils.DebugLogError(result.Error);
                OnEventNotify(SNResultCode.kError);
                return;
            }

            try
            {
                Dictionary<string, object> json = Json.Deserialize(result.RawResult) as Dictionary<string, object>;
                if (json == null)
                {
                    DebugUtils.DebugLogError("OnMyProfileCb - json is null.");
                    OnEventNotify(SNResultCode.kError);
                    return;
                }

                // my profile
                my_info_.id = json["id"] as string;
                my_info_.name = json["name"] as string;
                DebugUtils.Log("Facebook id: {0}, name: {1}.", my_info_.id, my_info_.name);

                // my picture
                var picture = json["picture"] as Dictionary<string, object>;
                var data = picture["data"] as Dictionary<string, object>;
                my_info_.url = data["url"] as string;
                StartCoroutine(RequestPicture(my_info_));

                OnEventNotify(SNResultCode.kMyProfile);
            }
            catch (Exception e)
            {
                DebugUtils.DebugLogError("Failure in OnMyProfileCb: " + e.ToString());
            }
        }
示例#58
0
    void DealWithUserName(IGraphResult result)
    {
        if (result.Error != null)
        {
            Debug.Log("problem with getting profile picture");
            FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,picture)", HttpMethod.GET, DealWithUserName);
            return;
        }

        profile = Util.DeserializeJSONProfile(result.RawResult);
        Text Usertext = UIFBUserName.GetComponent<Text>();
        Usertext.text = " " + profile["first_name"];
    }
        void OnInviteListCb (IGraphResult result)
        {
            try
            {
                Dictionary<string, object> json = Json.Deserialize(result.RawResult) as Dictionary<string, object>;
                if (json == null) {
                    DebugUtils.DebugLogError("OnInviteListCb - json is null.");
                    OnEventNotify(SNResultCode.kError);
                    return;
                }

                object invitable_friends = null;
                json.TryGetValue("invitable_friends", out invitable_friends);
                if (invitable_friends == null) {
                    DebugUtils.DebugLogError("OnInviteListCb - invitable_friends is null.");
                    OnEventNotify(SNResultCode.kError);
                    return;
                }

                invite_friends_.Clear();

                List<object> list = ((Dictionary<string, object>)invitable_friends)["data"] as List<object>;
                foreach (object item in list)
                {
                    Dictionary<string, object> info = item as Dictionary<string, object>;
                    Dictionary<string, object> picture = ((Dictionary<string, object>)info["picture"])["data"] as Dictionary<string, object>;

                    string url = picture["url"] as string;
                    UserInfo user = new UserInfo();
                    user.id = info["id"] as string;
                    user.name = info["name"] as string;
                    user.url = url;

                    invite_friends_.Add(user);
                    DebugUtils.DebugLog(">> id:{0} name:{1} url:{2}", user.id, user.name, user.url);
                }

                DebugUtils.Log("Succeeded in getting the invite list.");
                OnEventNotify(SNResultCode.kInviteList);

                if (auto_request_picture_ && invite_friends_.Count > 0)
                    StartCoroutine(RequestPictureList(invite_friends_));
            }
            catch (Exception e)
            {
                DebugUtils.DebugLogError("Failure in OnInviteListCb: " + e.ToString());
            }
        }
示例#60
0
 void DisplayProfilePic(IGraphResult result)
 {
     if (result.Texture != null) {
         ProfilePic = Sprite.Create (result.Texture, new Rect (0, 0, 128, 128), new Vector2 ());
     }
 }