scoreList [i].GetFacebookProfile () returns now but scores are linked to Facebook

0 votes

Hello everyone,

I am new to App42 and my question might sound trivial but I spent time on searching without any result still.

so here's the code:

private ScoreBoardResponse topNRankersCallBack = new ScoreBoardResponse ();

	private IEnumerator GetTopNRankers(int max)
	{	
		scoreBoardService = sp.BuildScoreBoardService (); // Initializing ScoreBoard Service.
		scoreBoardService.GetTopNRankers (cons.gameName, max, topNRankersCallBack);

		while (topNRankersCallBack.GetGame() == null) 
			yield return null;
		
		IList<Game.Score> scoreList = topNRankersCallBack.GetGame ().GetScoreList ();

		for (int i = 0; i < scoreList.Count; i++) 
		{	
			Game.Score.FacebookProfile fbProfile = scoreList [i].GetFacebookProfile ();

			if (fbProfile != null) 
				print ("fbProfile");
			 else
				print ("fbProfile is null");

			usersListPanel.transform.FindChild ("Content").GetChild (i).FindChild ("Text_username").GetComponent<Text> ().text = scoreList [i].GetUserName ();
			usersListPanel.transform.FindChild ("Content").GetChild (i).FindChild ("Text_score").GetComponent<Text> ().text = scoreList [i].GetValue ().ToString ();
		}
	}

And I always get printed "fb profile is null".

But username and score are displayed, which means I can't get the facebook profile from each score.

Here's were I link my user to fb.

public void FBLogin()
    {
        List<string> permissions = new List<string>();
        permissions.Add("public_profile");

        FB.LogInWithReadPermissions(permissions, AuthCallBack);
    }


SocialResponse callBack = new SocialResponse();

    void AuthCallBack(IResult result)
    {
        if (result.Error != null)
            print(result.Error);
        else
        {
			IsLoggedIn = FB.IsLoggedIn;

			if (FB.IsLoggedIn) 
			{
				FB.API("/me?fields=first_name" , HttpMethod.GET , ProfileNameCallBack);
				FB.API ("/me/picture?type=square&height=128&width=128", HttpMethod.GET, ProfilePictureCallBack);
			
				var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;

				s_Token = aToken.TokenString.ToString();
				s_UserID = aToken.UserId.ToString();


				socialService.LinkUserFacebookAccount(s_UserID , s_Token, callBack); 
			}
            else            
				print("FB is not logged in");            
        }

		print ("result: " + result);
    }

 

Any hints please ?

 

asked Dec 14, 2016 in Android by vaskenbakkalian (12 points)

1 Answer

+1 vote

Hi,

To get facebook leaderboard and FB profile along with it, please follow the below steps:

1. While saving scores, use FBID as user name

2. Use getTopNRankersFromFacebook API to get facebook leadrboard along with facebook profile

This is explained in this tutorial, please have a look and let me know if you have any queries.

Thanks.

answered Dec 15, 2016 by rajeev.etc (1,660 points)
@rajeev.etc thanks for the answer :)

However I don't need the rankers between the user and his/her friends.
I want ranks among all scores, but knowing the fact that we have the login option only as Login with facebook.

Every user has to login using facebook, considering all or almost all smart phone user have facebook accounts.
Yes, you are right. If all of your users are facebook users, then you can always send FBID as user name while saving scores and you can call getTopNRankersFromFacebook API to get the scores of the users. The response of this API will give you the scores, FB Profile of the user and the (index+1) of the array you receive in the response is the rank of the user available at that index.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...