OAuthException (#15) “必须使用应用程序 access_token 调用此方法”在尝试发布成就时

发布于 2024-12-03 22:55:33 字数 431 浏览 4 评论 0原文

当尝试通过以下方式为我的应用程序注册成就时,我不断收到 OAuthException (#15)“必须使用应用程序 access_token 调用此方法”:

FB.api("/APP_ID/achievements",
'post',
{achievement: FULL_ACHIEVEMENT_URL, access_token: ACCESS_TOKEN, display_order: 1},
function(response){
    getFlashMovieObject(referrer).fbDataCallback(response);
});

成就文件结构已验证并且正确,ACCESS_TOKEN 值也可以- 如果我将 HTTP 方法更改为“获取”,我会收到一个存储注册成就的数组。

您能告诉我如何使用 JS API 方法正确注册成就吗?

I'm constantly getting the OAuthException (#15) "This method must be called with an app access_token" while trying to register achievement for my app in the following way:

FB.api("/APP_ID/achievements",
'post',
{achievement: FULL_ACHIEVEMENT_URL, access_token: ACCESS_TOKEN, display_order: 1},
function(response){
    getFlashMovieObject(referrer).fbDataCallback(response);
});

Achievement file structure has been verified and is correct, ACCESS_TOKEN value is OK too - if I change HTTP method to 'get' I receive an array that stores registered achievements.

Can you, please, tell me how to register achievements correctly using the JS API methods?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心欲静而疯不止 2024-12-10 22:55:33

您无法从客户端 SDK(例如 javascript SDK)调用需要应用程序访问令牌的方法。 Javascript SDK 将始终为 API 调用隐式发送用户访问令牌。这是出于安全原因而设计的。

希望这有帮助

You can't call methods which require app access token from client SDKs such as javascript SDK. Javascript SDK will always send user access token implicitly for API calls. This is by design due to security reasons.

hope this helps

撩动你心 2024-12-10 22:55:33

似乎没有答案。我今天再次尝试了它 - 它只是开始工作。)

注意:即使您在调用时指定了相应的“方法”值,也不要指望 POST 请求出现在您的嗅探器中(就像我所做的:)) FB.api() - 无论哪种方式,您都会看到 GET 。这是一个强制的解决方法并且有效。

Seems there is no answer. I've tried it once again today - and it simply starts working.)

NOTE: don't expect for a POST request to appear in your sniffer (as I did:)) even if you have specified respective 'method' value while calling FB.api() - any way you'll see the GET one. It's a forced workaround and it works.

滿滿的愛 2024-12-10 22:55:33

我对此问题的解决方案是使用 PHP 获取 APP 访问令牌,然后将该令牌作为 post 对象的一部分传递。 USER 访问令牌将不起作用。

我必须为我正在构建的 Flash 游戏执行此操作,该游戏通过外部接口使用 Javascript SDK。您无法使用 Javascript 获取应用程序访问令牌,因为您会泄露应用程序秘密,这是一个安全问题。

<?php

$APPLICATION_ID = YOUR_APP_ID;
$APPLICATION_SECRET = YOUR_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);

?>

My solution to this problem was grabbing the APP access token with PHP and then passing that token as part of the post object. The USER access token will not work.

I had to do this for a Flash game I was building which uses the Javascript SDK through External interface. You can't get the app access token with Javascript because you would reveal the app secret which is a security issue.

<?php

$APPLICATION_ID = YOUR_APP_ID;
$APPLICATION_SECRET = YOUR_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);

?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文