“个人资料”选项卡中的 Facebook 应用程序:获取用户会话时出现问题

发布于 2024-09-24 05:25:27 字数 166 浏览 0 评论 0原文

我正在一个迷你应用程序中工作,它将有 3 个页面,我希望所有交互都发生在配置文件选项卡内。因此,使用 javascript,我想显示/隐藏一些我将填充的 div使用 FBJS ajax 对象。

我的问题是,我没有在 ajax 调用中获取用户会话。由于文档非常混乱,我最终不知道这是否可行。有什么想法吗?

I'm working in a mini-app, which will have 3 pages, and i want all the interaction to happen inside a profile-tab.So, using javascript, i want to show/hide a few divs, which i'll populate using the FBJS ajax object.

My problem is, i'm not getting the user session in the ajax calls.As documentation is extremely confusing, i've ended up not knowing if this is possible at all.Any ideas?

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

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

发布评论

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

评论(1

初相遇 2024-10-01 05:25:27

如果您需要通过配置文件选项卡上的 ajax 请求登录,您可以获取用户的 ID。例如:

var ajax = new Ajax();
ajax.responseType = Ajax.RAW;
ajax.ondone = function(data) {
    console.log('done');
    console.log(data);
}
ajax.onerror = function(data) {
    console.log('error');
    console.log(data);
}
ajax.requireLogin = true;
ajax.post('http://DOMAIN/add_story', {story: story});

requireLogin = true 部分将导致弹出授权窗口。如果他们同意,您可以使用 PHP SDK 在 AJAX 处理程序中获取用户 ID,例如:

$facebook->getUser();

You can get the user's id if you require login from your ajax request on a profile tab. For instance:

var ajax = new Ajax();
ajax.responseType = Ajax.RAW;
ajax.ondone = function(data) {
    console.log('done');
    console.log(data);
}
ajax.onerror = function(data) {
    console.log('error');
    console.log(data);
}
ajax.requireLogin = true;
ajax.post('http://DOMAIN/add_story', {story: story});

The requireLogin = true part will cause an authorization window to popup. If they agree, you can get the user ID in your AJAX handler using the PHP SDK, like:

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