Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to post a score from the Facebook JavaScript SDK

I want 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.

like image 513
Adam Avatar asked Aug 26 '11 23:08

Adam


People also ask

What is Facebook SDK for JavaScript?

The Facebook SDK for JavaScript provides a rich set of client-side functionality that: Enables you to use the Like Button and other Social Plugins on your site. Enables you to use Facebook Login to lower the barrier for people to sign up on your site. Makes it easy to call into Facebook's Graph API.

Is JavaScript used in Facebook?

Facebook only uses one language in the Front-end that is JavaScript. JavaScript is the most popular programming language today as it is used by almost every platform in the front-end development that you visit today.


1 Answers

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

like image 170
ShawnDaGeek Avatar answered Sep 22 '22 16:09

ShawnDaGeek