在graph api(javascript sdk)中添加测试用户

发布于 2024-10-19 19:20:11 字数 863 浏览 1 评论 0原文

我正在尝试添加几个来测试用户到我正在使用谷歌应用程序引擎和javascript sdk开发的应用程序。按照这个链接:,我尝试了这段代码:


FB.api ('/app_id/accounts/test-users', 'post', {installed:'true', permissions:'read_stream'}, function (response) {
    alert (response.id);
});

(app_id已更改为获得的应用程序ID在http://www.facebook.com/developers/apps.php

但我得到一个弹出窗口“未定义”。这段代码有什么问题?我找不到 javascript sdk 的任何示例。

根据同一个 Facebook 帮助页面,响应应该是:


{ 
  "id": "1231....",  
   "access_token":"1223134..." , 
   "login_url":"https://www.facebook.com/platform/test_account.." 
}

顺便说一句,如果我以自己的身份登录,


FB.api('/me', function(user) {
    welcomeMsg (user);
});

工作得很好,所以这不是应用程序激活的问题。

I am trying to add a couple to test users to an app I'm developing using google app engine and the javascript sdk. Following this link:, I tried this code:


FB.api ('/app_id/accounts/test-users', 'post', {installed:'true', permissions:'read_stream'}, function (response) {
    alert (response.id);
});

(app_id was changed to the App ID as obtained in http://www.facebook.com/developers/apps.php)

But I get a popup "undefined". What is wrong with this code? I could not find any example for the javascript sdk.

As per the same facebook help page, response is supposed to be:


{ 
  "id": "1231....",  
   "access_token":"1223134..." , 
   "login_url":"https://www.facebook.com/platform/test_account.." 
}

BTW, if I log in as myself,


FB.api('/me', function(user) {
    welcomeMsg (user);
});

works just fine, so it's not a problem with app activation.

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

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

发布评论

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

评论(1

┈┾☆殇 2024-10-26 19:20:11

我认为不可能使用 Javascript SDK 执行此类任务,该 SDK 旨在代表用户而不是应用程序进行调用。对于这种类型的调用,需要以应用程序身份进行身份验证,为此您需要应用程序 OAuth 令牌和密钥,而这些无法通过 Javascript 获得(出于安全原因,也不应该如此)。因此,最好的解决方案是在服务器端进行此调用。为此,您应该按照此处的“应用程序登录”说明进行操作 获取应用程序访问令牌,然后将该令牌传递给 /app_id/accounts/test-users API 调用(作为“access_token”参数)

I don't think it's possible to perform this type of task using the Javascript SDK, which is intended to make calls on behalf of a user, not an app. For this type of call, it's necessary to authenticate as the app, and for that you need the app OAuth token and secret, which aren't available via Javascript (nor should they be, for security reasons). So the best solution here is to make this call serverside. To do so, you should follow the "App Login" instructions here to get an app access token, and then pass that token in to the /app_id/accounts/test-users API call (as the "access_token" param)

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