예제 #1
0
	// Called when logged in to Facebook
	private void OnFBLoggedIn(FBResult p_result)
	{
//		Debug.Log(p_result.Text);
		if(string.IsNullOrEmpty(p_result.Error) && FB.IsLoggedIn)
		{
			this.fbLoginButton.SetActive(false);

			JToken resultJToken = JsonTools.ConvertStringToJToken(p_result.Text);
			if(resultJToken != null)
			{
				this.fbToken = (string)resultJToken["access_token"];
				LeanTween.alpha(
					this.goodFacebookLogo.gameObject,
					1f,
					1f)
					.setEase(LeanTweenType.easeInOutSine);

				BubbleGraph.Create((string)resultJToken["user_id"]);
			}
			else
			{
				Debug.LogError("Problem reading Facebook login result JSON");
			}
		}
		else
		{
			LeanTween.alpha(
				this.goodFacebookLogo.gameObject,
				1f,
				0.2f)
				.setEase(LeanTweenType.easeInOutSine)
				.setLoopPingPong(1);
		}
	}
    private void FBAPICallback(FBResult result)
    {
        if (!String.IsNullOrEmpty(result.Error)) {
            Debug.Log ("FBAPICallback: Error getting user info: + "+ result.Error);
            // Log the user out, the error could be due to an OAuth exception
            ParseFBLogout();
        } else {
            // Got user profile info
            var resultObject = Json.Deserialize(result.Text) as Dictionary<string, object>;
            var userProfile = new Dictionary<string, string>();

            userProfile["facebookId"] = getDataValueForKey(resultObject, "id");
            userProfile["name"] = getDataValueForKey(resultObject, "name");
            object location;
            if (resultObject.TryGetValue("location", out location)) {
                userProfile["location"] = (string)(((Dictionary<string, object>)location)["name"]);
            }
            userProfile["gender"] = getDataValueForKey(resultObject, "gender");
            userProfile["birthday"] = getDataValueForKey(resultObject, "birthday");
            userProfile["relationship"] = getDataValueForKey(resultObject, "relationship_status");
            if (userProfile["facebookId"] != "") {
                userProfile["pictureURL"] = "https://graph.facebook.com/" + userProfile["facebookId"] + "/picture?type=large&return_ssl_resources=1";
            }

            var emptyValueKeys = userProfile
                .Where(pair => String.IsNullOrEmpty(pair.Value))
                    .Select(pair => pair.Key).ToList();
            foreach (var key in emptyValueKeys) {
                userProfile.Remove(key);
            }

            StartCoroutine("saveUserProfile", userProfile);
        }
    }
    private void FBAPICallback(FBResult result)
    {
        if (!String.IsNullOrEmpty(result.Error)) {
            // Handle error
        } else {
            // Got user profile info
            var resultObject = Json.Deserialize(result.Text) as Dictionary<string, object>;
            var userProfile = new Dictionary<string, string>();

            userProfile["facebookId"] = getDataValueForKey(resultObject, "id");
            userProfile["name"] = getDataValueForKey(resultObject, "name");
            object location;
            if (resultObject.TryGetValue("location", out location)) {
                userProfile["location"] = (string)(((Dictionary<string, object>)location)["name"]);
            }
            userProfile["locale"] = getDataValueForKey(resultObject, "locale");
            userProfile["gender"] = getDataValueForKey(resultObject, "gender");
            //userProfile["birthday"] = getDataValueForKey(resultObject, "birthday");
            //userProfile["relationship"] = getDataValueForKey(resultObject, "relationship_status");
            if (userProfile["facebookId"] != "") {
                userProfile["pictureURL"] =
                    "https://graph.facebook.com/" + userProfile["facebookId"] + "/picture?type=large&width=128&height=128&return_ssl_resources=1";
            }
            //userProfile["score"] = "555555";
            StartCoroutine("saveUserData", userProfile);
        }
    }
    void InvitedCallback(FBResult result)
    {
        Debug.Log (result.Text);
        //Screen.orientation = ScreenOrientation.LandscapeLeft;
        if(result.Error != null)
        {
            //Debug.LogError("OnActionShared: Error: " + result.Error);
        }

        if (result == null || result.Error != null)
        {
            //Do something request failed

        }
        else
        {
            var responseObject = Facebook.MiniJSON.Json.Deserialize(result.Text) as System.Collections.Generic.Dictionary<string, object>;
            object obj = 0;
            if (responseObject == null || responseObject.Count <= 0 || responseObject.TryGetValue("cancelled", out obj))
            {
                //Debug.LogWarning("Request cancelled");
                //Do something when user cancelled
            }
            else if (responseObject.TryGetValue("id", out obj) || responseObject.TryGetValue("post_id", out obj))
            {
                //Debug.LogWarning("Request Send");
                //Do something it is succeeded
            }
        }
    }
    // FB.api callback for friends
    void Callback2(FBResult result)
    {
        Debug.Log (result.Text);

        IDictionary data = (IDictionary) Json.Deserialize(result.Text);

        IList friends = (IList) data["data"];

        string name;
        string id;

        foreach (IDictionary friend in friends) {

            name = (string)friend["name"];
            id = (string)friend["id"];
            url = (string)((IDictionary)((IDictionary)friend["picture"])["data"])["url"];

            StartCoroutine(getTextureByURL());

            // fetch only one row
            break;
        }

        Debug.Log ("Finished API call.");
    }
예제 #6
0
	void OnFacebookLogin(FBResult result)
	{
		if (FB.IsLoggedIn) 
		{
			// It worked
			Debug.Log("Facebook auth success");

			// Now we login using Braincloud
			BrainCloudWrapper.GetBC().AuthenticationService.AuthenticateFacebook(
				FB.UserId, 
				FB.AccessToken, 
				true, 
				OnBraincloudAuthenticateFacebookSuccess, 
				OnBraincloudAuthenticateFacebookFailed);

			// Meanwhile, we will fetch info about our player, to get the profile pic and name
			FB.API("/me?fields=name,picture", Facebook.HttpMethod.GET, OnFacebookMe);
		}
		else
		{
			// It failed
			Debug.LogError("Facebook auth failed");
			m_isConnecting = false;
			spinner.gameObject.SetActive(false); // Hide spinner
		}
	}
예제 #7
0
 void LoginCallback(FBResult result)
 {
     if (FB.IsLoggedIn)
     {
         PostScore(PlayerPrefs.GetInt("Last Score"));
     }
 }
 //Check Login
 void LoginCallback(FBResult result)
 {
     if (!FB.IsLoggedIn)
     {
         gamestate.isfacebookclick = false;
         //FB.Login ("public_profile,email,user_friends", LoginCallback);
         //Screen.orientation = ScreenOrientation.LandscapeRight;
         //gamestate.stategame = GameState.StateGame.Reborn;
     }
     else
     {
         //gamestate.stategame = GameState.StateGame.Reborn;
         showNotification();
         StartCoroutine("ParseLogin");
         //Screen.orientation = ScreenOrientation.LandscapeRight;
         /*FB.Feed(
             link: "http://s1.anh.im/2015/05/01/icon17e07.png",
             linkName: "Test thôi mà",
             linkCaption: "Test tí cho vui",
             linkDescription: "Test nào",
             picture: "http://s1.anh.im/2015/05/01/icon17e07.png",
             callback :SharedCallback
             );*/
     }
 }
예제 #9
0
 void LoginCallback(FBResult result)
 {
     Debug.Log ("logged in!" + FB.UserId);//use this to sync progress etc
     Debug.Log("login result: " + result.Text);
     FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
     FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, MyPictureCallback);
 }
예제 #10
0
    void GetProfileCallback(FBResult result)
    {
        if(result.Error != null)
        {
            if (attemptsToLoadProfile < 3)
            {
                //retry the request if an error has occured, probably need to check how many times this fails.
                GetProfile();
                attemptsToLoadProfile++;
            }
            else
            {
                Debug.Log("Failed to GetProfile: " + result.Text);
            }
        }
        else
        {
            try
            {
                var pure = result.Text;

                ProfileData = Util.DeserializeJSONProfile(result.Text);
                var friends = Util.DeserializeJSONFriends(result.Text);

                //Use the Console tab in the Editor to view this data without using breakpoints
                Debug.Log(GetValueFromPofile("first_name") + " " + GetValueFromPofile("last_name"));

            }
            catch(Exception ex)
            {
                //exceptions are never filled with any data when this fails?
                Debug.Log(ex.Message);
            }
        }
    }
예제 #11
0
	private void OnFBAuth(FBResult result) {

		SPFacebook.Instance.OnAuthCompleteAction -= OnFBAuth;


		if(SPFacebook.Instance.IsLoggedIn) {

			SPFacebook.Instance.OnPostingCompleteAction += HandleOnPostingCompleteAction;
			SPFacebook.instance.Post(_toId,
			                         _link,
			                         _linkName,
			                         _linkCaption,
			                         _linkDescription,
			                         _picture,
			                         _actionName,
			                         _actionLink,
			                         _reference);

		} else {
			FBResult res =  new FBResult("", "Auth failed");
			FBPostResult postResult =  new FBPostResult(res);

			ActionComplete(postResult);
		}



	}
예제 #12
0
파일: FBGet.cs 프로젝트: alusor/TecnoRacing
    private void APICallback(FBResult result)
    {
        
        textoui.text = result.Text;

        Debug.Log(FB.UserId);
    }
예제 #13
0
 public static void API(
     string endpoint,
     HttpMethod method,
     FacebookDelegate callback)
 {
     if (method != HttpMethod.GET) throw new NotImplementedException();
     Task.Run(async () =>
     {
         FacebookClient fb = new FacebookClient(_fbSessionClient.CurrentAccessTokenData.AccessToken);
         FBResult fbResult = null;
         try
         {
             var apiCall = await fb.GetTaskAsync(endpoint, null);
             if (apiCall != null)
             {
                 fbResult = new FBResult();
                 fbResult.Text = apiCall.ToString();
                 fbResult.Json = apiCall as JsonObject;
             }
         }
         catch (Exception ex)
         {
             fbResult = new FBResult();
             fbResult.Error = ex.Message;
         }
         if (callback != null)
         {
             Utils.RunOnUnityAppThread(() => { callback(fbResult); });
         }
     });
 }
예제 #14
0
	void FBLoginCallback(FBResult result) {                                                                                          
		FbDebug.Log("LoginCallback");                                                          
		if (FB.IsLoggedIn) {                                                                                      
			Debug.LogWarning("Logged in. ID: " + FB.UserId);
			StartCoroutine(FBTakeScreenshot());
		}                                                                                      
	}
예제 #15
0
 protected void handleResult(FBResult result)
 {
     lastResponseTexture = null;
     // Some platforms return the empty string instead of null.
     if (!String.IsNullOrEmpty(result.Error))
     {
         status = "Error - Check log for details";
         lastResponse = "Error Response:\n" + result.Error;
         LogView.AddLog(result.Error);
     } else if (!String.IsNullOrEmpty(result.Text))
     {
         status = "Success - Check log for details";
         lastResponse = "Success Response:\n" + result.Text;
         LogView.AddLog(result.Text);
     } else if (result.Texture != null)
     {
         status = "Success - Check log for details";
         lastResponseTexture = result.Texture;
         lastResponse = "Success Response: texture\n";
         LogView.AddLog("Success - Failed to display details since response was a texture");
     } else
     {
         lastResponse = "Empty Response\n";
         LogView.AddLog(lastResponse);
     }
 }
예제 #16
0
    private void OnFBAuthFailed()
    {
        SPFacebook.instance.removeEventListener(FacebookEvents.AUTHENTICATION_FAILED,  	 	OnFBAuthFailed);
        SPFacebook.instance.removeEventListener(FacebookEvents.AUTHENTICATION_SUCCEEDED,  	OnFBAuth);

        FBResult res =  new FBResult("", "Auth failed");
        dispatch(BaseEvent.COMPLETE, res);
    }
예제 #17
0
 void LoginCallback(FBResult result)
 {
     FbDebug.Log("call login: "******"login result: " + result.Text);
     FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
     FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, MyPictureCallback);
     FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);
 }
예제 #18
0
 void LoginCallback(FBResult result)
 {
     FbDebug.Log("call login: "******"login result: " + result.Text);
     FB.API("/me?fields=id,first_name,friends.limit(100).fields(first_name,id)", Facebook.HttpMethod.GET, APICallback);
     FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, MyPictureCallback);
     FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);
 }
예제 #19
0
 bool WasAppPermissionRemovedByUser(
     FBResult Result
     )
 {
     return((Result != null) &&
            (!Result.Succeeded) &&
            (Result.ErrorInfo.Code == (int)Facebook.ErrorCode.ErrorCodeOauthException));
 }
예제 #20
0
파일: GUIFB.cs 프로젝트: MizzKii/PuruDash2D
	void LoginCallback(FBResult result)
	{
		if (result.Error != null)
			Debug.LogError("Error Response:\n" + result.Error);
		else if (!FB.IsLoggedIn) {
			Debug.Log("Login cancelled by Player");
		}
	}
    private void OnPost(CEvent e)
    {
        FBResult res = e.data as FBResult;

        Debug.Log(res.Text);

        statusMessage = "Posting complete";
    }
예제 #22
0
 //If failed to GET picture, Show result in console
 public static void FriendPictureCallback(FBResult result)
 {
     if (result.Error != null)
     {
         Debug.LogError(result.Error);
         return;
     }
 }
예제 #23
0
파일: MainMenu.cs 프로젝트: junian/Octosky
 void LoginCallback(FBResult result)
 {
     FbDebug.Log("Login callback");
     if(FB.IsLoggedIn)
     {
         OnFBLoggedIn();
     }
 }
예제 #24
0
    void OnGetMe(FBResult result)
    {
        var dictionary = Json.Deserialize(result.Text) as Dictionary<string, object>;
        PersonalName.text = dictionary["name"] as string;
        string facebookId = dictionary["id"] as string;

        StartCoroutine("GetProfilePicture", facebookId);
    }
예제 #25
0
    /// <summary>
    /// Callback used when user's profile info loads.
    /// </summary>
    /// <param name="result"></param>
    void OnProfileInfoLoaded(FBResult result)
    {
        Dictionary <string, object> profileInfo = (Dictionary <string, object>)Json.Deserialize(result.Text);

        facebookName = profileInfo["name"].ToString();

        FB.API("me/picture?width=100&height=100&redirect=false", Facebook.HttpMethod.GET, OnPictureLoaded);
    }
예제 #26
0
파일: GuiScore.cs 프로젝트: Milton761/SRM
	private void FBLoginCallback(FBResult result) {
		if(FB.IsLoggedIn) {
		//	showLoggedIn();
			StartCoroutine("ParseLogin");
		} else {
			Debug.Log ("FBLoginCallback: User canceled login");
		}
	}
 public static void FriendPictureCallback(FBResult result)
 {
     if (result.Error != null)
     {
         Debug.LogError(result.Error);
         return;
     }
 }
    /// <summary>
    /// Callback used when user's profile info loads.
    /// </summary>
    /// <param name="result"></param>
    void OnProfileInfoLoaded(FBResult result)
    {
        Dictionary<string, object> profileInfo = (Dictionary<string, object>)Json.Deserialize(result.Text);

        facebookName = profileInfo["name"].ToString();

        FB.API("me/picture?width=100&height=100&redirect=false", Facebook.HttpMethod.GET, OnPictureLoaded);
    }
예제 #29
0
	void LoginCallback(FBResult result)                                                        
	{                                                                                                                                                
		
		if (FB.IsLoggedIn)                                                                     
		{                                                                                      
			OnLoggedIn();                                                                      
		}                                                                                      
	}                                                                                          
예제 #30
0
        private async void OnLoginLogout(EventArgs obj)
        {
            if (FBGlobalScope.IsLoggedIn)
            {
                await FBGlobalScope.Session.LogoutAsync();

                FBGlobalScope.IsLoggedIn = false;
                NavigationService.ShellViewModel.PrimaryItems[0].Label = $"Login";
                var loginItem = NavigationService.ShellViewModel.PrimaryItems[0];
                NavigationService.ShellViewModel.PrimaryItems.Clear();
                NavigationService.ShellViewModel.PrimaryItems.Add(loginItem);
            }
            else
            {
                int      count  = 0;
                FBResult result = null;
                do
                {
                    FBGlobalScope.Initialize();
                    result = await FBGlobalScope.Session.LoginAsync(FBGlobalScope.Permissions, SessionLoginBehavior.WebView);

                    if (result.Succeeded)
                    {
                        FBGlobalScope.IsLoggedIn = true;
                        await FBGlobalScope.PopulateUserData();

                        NavigationService.ShellViewModel.PrimaryItems[0].Label = $"Logged in as {FBGlobalScope.User.Name}";

                        foreach (var page in FBGlobalScope.Pages)
                        {
                            string key = $"{typeof(PostViewModel).FullName}{page.Id}";
                            NavigationService.Configure(key, typeof(PostPage));
                            NavigationService.ShellViewModel.PrimaryItems.Add(new ShellNavigationItem(
                                                                                  page.Name,
                                                                                  Symbol.Page2,
                                                                                  typeof(PostViewModel).FullName,
                                                                                  page
                                                                                  ));
                        }
                        if (FBGlobalScope.Pages.Count > 0)
                        {
                            NavigationService.Navigate($"{typeof(PostViewModel).FullName}{FBGlobalScope.Pages[0].Id}", FBGlobalScope.Pages[0]);
                        }
                    }
                    else
                    {
                        await FBGlobalScope.Session.LogoutAsync();

                        FBGlobalScope.IsLoggedIn = false;
                        NavigationService.ShellViewModel.PrimaryItems[0].Label = $"Login";
                        var loginItem = NavigationService.ShellViewModel.PrimaryItems[0];
                        NavigationService.ShellViewModel.PrimaryItems.Clear();
                        NavigationService.ShellViewModel.PrimaryItems.Add(loginItem);
                    }
                    count++;
                }while (!result.Succeeded && count < 3);
            }
        }
예제 #31
0
    void UserCallBack(FBResult result)
    {
        Debug.Log("UserCallBack");

        if (result.Error != null)
        {
            Debug.Log("UserCallBack - user graph request failed: " + result.Error + " - " + result.Text);

#if PROPELLER_SDK
            PropellerSDK.SdkSocialLoginCompleted(null);
#endif

            if (socialPost != SocialPost.NONE)
            {
#if PROPELLER_SDK
                switch (socialPost)
                {
                case SocialPost.INVITE:
                    PropellerSDK.SdkSocialInviteCompleted();
                    break;

                case SocialPost.SHARE:
                    PropellerSDK.SdkSocialShareCompleted();
                    break;
                }
#endif

                socialPost     = SocialPost.NONE;
                socialPostData = null;
            }

            return;
        }

        string get_data = result.Text;

        var dict = Json.Deserialize(get_data) as IDictionary;
        fbname      = dict ["name"].ToString();
        fbemail     = dict ["email"].ToString();
        fbgender    = dict ["gender"].ToString();
        fbfirstname = dict ["first_name"].ToString();

        PushFBDataToFuel();

        if (socialPost != SocialPost.NONE)
        {
            switch (socialPost)
            {
            case SocialPost.INVITE:
                onSocialInviteClicked(socialPostData);
                break;

            case SocialPost.SHARE:
                onSocialShareClicked(socialPostData);
                break;
            }
        }
    }
예제 #32
0
 void InviteFriendsCallback(FBResult result)
 {
     PopupManager.Instance.CloseLoadingPopup();
     if (result.Error == null)
     {
         HUDManager.Instance.AddFlyText(Localization.Get("InviteFriend_Success"), Vector3.zero, 40, Color.green, 0, 2f);
     }
     Debug.Log("InviteFriendsCallback " + result.Text);
 }
예제 #33
0
    void OnLogin(FBResult result)
    {
        if (!NetworkingManager.Connected)
        {
            NetworkingManager.Connect();
        }

        Application.LoadLevel("Lobby");
    }
예제 #34
0
    /// <summary>
    /// Callback used when user's facebook picture loads.
    /// </summary>
    /// <param name="result"></param>
    void OnPictureLoaded(FBResult result)
    {
        Dictionary <string, object> receivedInfo = (Dictionary <string, object>)Json.Deserialize(result.Text);
        Dictionary <string, object> pictureInfo  = (Dictionary <string, object>)receivedInfo["data"];

        facebookPictureUrl = pictureInfo["url"].ToString();

        this.OnFacebookLoginCompletedCallback(FB.AccessToken, facebookName, facebookPictureUrl);
    }
예제 #35
0
    void LoginCallback(FBResult result)
    {
        Util.Log("LoginCallback");

        if (FB.IsLoggedIn)
        {
            OnLoggedIn();
        }
    }
예제 #36
0
    void OnGetMe(FBResult result)
    {
        var dictionary = Json.Deserialize(result.Text) as Dictionary <string, object>;

        PersonalName.text = dictionary["name"] as string;
        string facebookId = dictionary["id"] as string;

        StartCoroutine("GetProfilePicture", facebookId);
    }
예제 #37
0
 void APICallback(FBResult response)
 {
     profile = FBUtil.DeserializeJSONProfile(response.Text);
     GameStateManager.Username = profile["first_name"];
     StartCoroutine(
         FBUtil.GetPictureTexture(facebookID: FB.UserId, callback: delegate(Texture t) { GameStateManager.UserTexture = t; })
     );
     friends = FBUtil.DeserializeJSONFriends(response.Text);
 }
예제 #38
0
 private void FacebookLoginCallback(FBResult result)
 {
     GetComponent <CharacterList> ().enabled = true;
     if (FB.IsLoggedIn)
     {
         credentials.AddLogin("graph.facebook.com", FB.AccessToken);
         LoadFromDataset();
     }
 }
예제 #39
0
	private void OnDeleteActionFinish(FBResult result) {
	
		if(result.Error != null) {
			State = FBAppRequestState.Deleted;
		}


		OnDeleteRequestFinished(result);
	}
    // Handles the Profile Picture
    void HandleFBPic(FBResult result)
    {
        // Retrieve the Profile Picture
        t2ProfileImage = result.Texture;
        Debug.Log(t2ProfileImage);

        // Set Image Loaded to true
        bImageLoaded = true;
    }
예제 #41
0
    private void OnAppRequestFailed_AndroidCB(string error)
    {
        FBResult res = new FBResult("", error);

        FBAppRequestResult r = new FBAppRequestResult();

        r.Result = res;
        OnAppRequestCompleteAction(r);
    }
예제 #42
0
 void Callback(FBResult result)
 {
     if (result.Error == null)
     {
         var dict = Json.Deserialize(result.Text) as Dictionary <string, object>;
         Name.text = dict["name"] as string;
         Show();
     }
 }
예제 #43
0
    void OnLogin(FBResult result)
    {
        if (!NetworkingManager.Connected)
        {
            NetworkingManager.Connect();
        }

        Application.LoadLevel("Lobby");
    }
예제 #44
0
    private void OnFBAuthFailed()
    {
        SPFacebook.instance.removeEventListener(FacebookEvents.AUTHENTICATION_FAILED, OnFBAuthFailed);
        SPFacebook.instance.removeEventListener(FacebookEvents.AUTHENTICATION_SUCCEEDED, OnFBAuth);

        FBResult res = new FBResult("", "Auth failed");

        dispatch(BaseEvent.COMPLETE, res);
    }
예제 #45
0
    void OnProfilePictureCallback(FBResult pResult)
    {
        if (userProfileImage != null)
        {
            userProfileImage.sprite = Sprite.Create(pResult.Texture, new Rect(0, 0, 128, 128), Vector2.zero);
        }

        FBLoginButton.gameObject.SetActive(false);
    }
예제 #46
0
    void AppRequestCallback(FBResult result)
    {
        Debug.Log("AppRequestCallback=" + result.Text);

        g.facebookEvent = "";

        StartCoroutine(popupFriendControl.MakeFriendGrid());
        popupFriendControl.fbLoginInfo.SetActive(false);
    }
예제 #47
0
    static void OnGetMe(FBResult result)
    {
        var dictionary = Json.Deserialize(result.Text) as Dictionary <string, object>;

        Name       = dictionary["name"] as string;
        FacebookId = dictionary["id"] as string;

        Debug.Log(Name + " (" + FacebookId + ")");
    }
 private void GetFriendUsersCallback(FBResult result)
 {
     if (result.Error == null)
     {
         IDictionary   dict  = Facebook.MiniJSON.Json.Deserialize(result.Text) as IDictionary;
         List <object> users = dict["data"] as List <object>;
         OnFriendsLoadedDelegate(users);
     }
 }
예제 #49
0
    public static void LoginCallback(FBResult result)
    {
        FbDebug.Log("call login: "******"login result: " + result.Text);

        FB.API("/me?fields=id,name,first_name,last_name,gender,locale,currency,friends.limit(1000).fields(first_name,last_name,id)", Facebook.HttpMethod.GET, FaceBook.APICallback);
        FacebookPictureDownloader.EnQueue(FB.UserId);
        FB.API("/app/scores?fields=score,user.limit(1000)", Facebook.HttpMethod.GET, ScoresCallback);
    }
 private void OnFacebookFeed(FBResult result)
 //private void OnFacebookFeed(IShareResult result)
 {
     if (result.Error != null)
     {
         Debug.Log("There was an error logging into Facebook!");
     }
     OnHideUnity(true);
 }
예제 #51
0
    private void OnPostFailed(CEvent e)
    {
        FBResult res = e.data as FBResult;

        //can be null if user wasn't logged in
        if (res != null)
        {
        }
    }
예제 #52
0
 void AuthCallback(FBResult result)
 {
     if (FB.IsLoggedIn){
         OnLoggedIn();
         //StartCoroutine(RegisterToCouchbase());
     }else{
         Debug.Log("Failed Logged in");
     }
 }
예제 #53
0
    void ScoresCallback(FBResult result)
    {
        Util.Log("ScoresCallback");
        if (result.Error != null)
        {
            Util.LogError(result.Error);
            return;
        }

        scores = new List <object>();
        List <object> scoresList = Util.DeserializeScores(result.Text);

        foreach (object score in scoresList)
        {
            var entry = (Dictionary <string, object>)score;
            var user  = (Dictionary <string, object>)entry["user"];

            string userId = (string)user["id"];

            if (string.Equals(userId, FB.UserId))
            {
                // This entry is the current player
                int playerHighScore = getScoreFromEntry(entry);
                Util.Log("Local players score on server is " + playerHighScore);
                if (playerHighScore < GameStateManager.Score)
                {
                    Util.Log("Locally overriding with just acquired score: " + GameStateManager.Score);
                    playerHighScore = GameStateManager.Score;
                }

                entry["score"]             = playerHighScore.ToString();
                GameStateManager.HighScore = playerHighScore;
            }

            scores.Add(entry);
            if (!friendImages.ContainsKey(userId))
            {
                // We don't have this players image yet, request it now
                LoadPicture(Util.GetPictureURL(userId, 128, 128), pictureTexture =>
                {
                    if (pictureTexture != null)
                    {
                        friendImages.Add(userId, pictureTexture);
                    }
                });
            }
        }

        // Now sort the entries based on score
        scores.Sort(delegate(object firstObj,
                             object secondObj)
        {
            return(-getScoreFromEntry(firstObj).CompareTo(getScoreFromEntry(secondObj)));
        }
                    );
    }
예제 #54
0
 void PictureCallBack(FBResult result)
 {
     if (result.Error != null)           // If there is an Error because Error value did not return null, instead it returned an error
     {
         Debug.Log("Error getting profile picture.");
         //FB.API(Util.GetPictureURL("me",48,48),Facebook.HttpMethod.GET,PictureCallBack);//Profile Picture - Can Casue infinite loop
         return;
     }
     avatarImage = result.Texture;
 }
예제 #55
0
파일: Util.cs 프로젝트: amisiak7/jewels2
    public static void FriendPictureCallback(FBResult result)
    {
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }

        //GameStateManager.FriendTexture = result.Texture;
    }
예제 #56
0
    private void OnAppRequestFailed_AndroidCB(string error)
    {
        FBResult res = new FBResult("", error);

        FBAppRequestResult r = new FBAppRequestResult();

        r.Result = res;
        dispatch(FacebookEvents.APP_REQUEST_COMPLETE, r);
        OnAppRequestCompleteAction(r);
    }
예제 #57
0
    /// <summary>
    /// Called after getting the user information
    /// </summary>
    /// <param name="result"> The result ofthe callback </param>
    private void APICallback(FBResult result) {
        if (result.Error != null) {
            Debug.LogError(result.Error);
            return;
        }

        var data = JSONNode.Parse(result.Text);
        FacebookUser user = new FacebookUser(data["first_name"] + data["last_name"], data["id"].AsInt, null /*TODO get picture data from lin data["picture"]*/);
        SocialNetworkManager_Persistent.Instance.userInformation.facebook = user;
    }
예제 #58
0
    private void OnDeleteActionFinish(FBResult result)
    {
        if (result.Error != null)
        {
            State = FBAppRequestState.Deleted;
        }


        OnDeleteRequestFinished(result);
    }
예제 #59
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"];
        }
    }
예제 #60
0
    public static void FriendPictureCallback(FBResult result)
    {
        if (result.Error != null)
        {
            Debug.LogError(result.Error);
            return;
        }

        //GameStateManager.FriendTexture = result.Texture;
    }