• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by jamiewhitephd · Apr 15, 2014 at 06:05 PM · facebookscore

Facebook SDK - “FB.API” not saving or loading scores

I'm creating a game for the Facebook Canvas using the official Facebook SDK. Despite using code directly from the Facebook Unity example, I cannot save nor load a score value. I receive no error or message whatsoever - A value of 0 is always returned when I attempt to retrieve the score. Everything else (logging in, posting to the news feed, etc.) is working fine - just not the score management. Also, this occurs both in the Unity editor and on the Facebook canvas itself.

I save the player's score like this:

 public void SaveScore(int _score)
 {
     _fbScore = _score;
 
     var _query = new Dictionary<string, string>();
     _query["score"] = _fbScore.ToString();
 
     FB.API("/me/scores", Facebook.HttpMethod.POST, delegate(FBResult r) { Util.Log("Result: " + r.Text); }, _query);
 
     //FB.API ("/me/scores", Facebook.HttpMethod.POST, ScoreSaveCallBack, scoreData);
     _hiScoreText.text = _fbScore.ToString();
 }

I then try to retrieve the score with this method:

 public void GetHighScore()
 {
     if (_fbIsInited)
         FB.API ("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, GetScoreCallBack);
 }

Callback method:

 void GetScoreCallBack(FBResult _result)
 {
     try 
     {
         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))
             {
                 _fbScore = GetScoreFromEntry(_entry);
                 _hiScoreText.text = _fbScore.ToString();
                 Debug.Log("FB SCORE: + " + _fbScore);
             }
         }
     }
     catch (System.Exception _e)
     {
         Debug.Log(_e.Message);
     }
 }

As the score returned is always 0, I do not know whether the problem is with the save or load methods.

EDIT: To make matters worse, out of nowhere, I've started getting these errors when I attempt to post the score:

 You are trying to load data from a www stream which had the following error when downloading.
 403 Forbidden
 UnityEngine.WWW:get_text()
 FBResult:get_Text()
 FacebookManager:<SaveScore>m__0(FBResult) (at Assets/Scripts/Facebook/FacebookManager.cs:138)
 Facebook.<Start>c__Iterator0:MoveNext()

I haven't made any changes to the code, they just started appearing every time!

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mickee77 · May 01, 2014 at 09:19 PM 0
Share

I have exactly the same problem, help would be appreciated please. The problem seems to be about permissions allowed by the app or user (your account). As 403 forbidden tell us that the server receive the request but dont have permission to send us the requested ressource (the /me/scores node).

avatar image $$anonymous$$ · May 08, 2014 at 08:09 PM 0
Share

I have the samo problem too. But strangely i can load the profil picture and draw it.

avatar image $$anonymous$$ · May 11, 2014 at 12:52 PM 0
Share

When I build for iOS and tried again in the editor all was fine.

avatar image Ekta-Mehta-D · Jun 06, 2014 at 07:12 AM 0
Share

hey guys.. you got some solution?? i am also stuck at this point.. please helpp me if you got any solution..

avatar image Crevecoeur · Jun 18, 2014 at 08:28 AM 0
Share

I'm also at this point trying to send my score from my app. I've tried with Friend Smash, the example game from FB (apps.facebook.com/friendsmashsample/). Score stays on zero... When I use graph api requesting /me/scores/ nothing appears except "data"...

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

26 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get Facebook friend's name, score, and picture 1 Answer

I can see/send invites to non-app user friends on canvas app but not on android/ios 0 Answers

facebook with unity problem 0 Answers

Deserialize Facebook friends result 1 Answer

How to "Like" facebook page ? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges