Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
787 views
in Technique[技术] by (71.8m points)

facebook - This method must be called with an app access_token

After days of searching the forums/net, I still couldn't get this to go away and use the SCORE graph api

{
  "error": {
  "message": "(#15) This method must be called with an app access_token.", 
  "type": "OAuthException", 
  "code": 15
  }
}

On the graph api explorer i tried using this (with publish_actions permission activated & POST selected):

https://graph.facebook.com/100003429183160/scores?score=555&access_token=APP_ACCESS_TOKEN

Having no luck :(

I have done the following:

? Set my app as a GAME, the basic info, setup the Auth Dialog

? Setup the Open Graph type, object, aggregation

? Use/Verify the right APP ACCESS_TOKEN (not the user access_token) via Access Token Tool

? Use the publish_actions permission

? Made sure it's using POST as method

? Tried appID|appSecret as an app access_token

? Verified that I indeed installed the app

? Was able to post to a wall via graph api, pull friends list and photos, etc.

Any clues what else could cause this not to run with the Graph API Explorer?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Answer:-

Actually for using SCORE Graph API you need the "Application access token" which is different than a normal access token

So if you want your task to be done GET an Application access token by using the following script.......

And then replace the generated application_access_token with old access_token, that's it

$APPLICATION_ID = "APP_ID";
$APPLICATION_SECRET = "APP_SECRET";

$token_url =    "https://graph.facebook.com/oauth/access_token?" .
                "client_id=" . $APPLICATION_ID .
                "&client_secret=" . $APPLICATION_SECRET .
                "&grant_type=client_credentials";
$app_token = file_get_contents($token_url);

After getting this application access token you can easily do this task.

When You Need An Application Access Token

You need to use a Facebook application access token when you have a process that acts on behalf of the application, rather than on behalf of a particular user. This happens when you access your Facebook Insights data for your app via the graph, and also when you want to create test Facebook users for your app.

Sadly, the documentation for this is buried in the authentication guide for the Facebook graph API.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...