开发者

How to post a score from the Facebook JavaScript SDK

开发者 https://www.devze.com 2023-03-30 22:04 出处:网络
I wan开发者_如何学运维t to submit a score from the JavaScript SDK. Here\'s my current attempt:

I wan开发者_如何学运维t to submit a score from the JavaScript SDK. Here's my current attempt:

FB.api("/me/scores", 'post', {score: seconds, access_token: FB.getSession().access_token}, function(response){
       if (!response || response.error) {
          console.error(response);
       } else {
          console.log(response);
       }
});

I get the error message:

(#15) This method must be called with an app access_token.

Since I am passing the access token, why doesn't this work?

Thanks.


You need to use an app access_token to update score, which is different from session or user token.

http://developers.facebook.com/docs/authentication/#applogin

2ndly you will need to use the session or user token to read the scores, then use an app token to delete.

http://developers.facebook.com/docs/reference/api/application/#scores


FB.getSession().access_token will not return an app access token. App access tokens are intended to be used server-side and are retrieved using the app ID and app secret as described here: https://developers.facebook.com/docs/authentication/#applogin.

NOTE: The app secret is like your password; it should never be sent to the client or embedded in client-side code.

0

精彩评论

暂无评论...
验证码 换一张
取 消