添加到时间轴插件的回调?

发布于 2024-12-07 20:59:35 字数 353 浏览 0 评论 0原文

当用户访问我的网站并尝试允许publish_action权限时,他将点击'添加到时间线'插件按钮。
然后出现一个弹出对话框,用户将允许所需的权限。
我想知道的是,我们是否可以指定在用户允许权限后调用的任何回调函数。

我知道我们可以通过 FB.Event.subscribe 订阅“edge.create”事件,但我找不到“add-to-timeline”的类似解决方案。
至少,据我所知,它没有写在其文档中。
有人可以帮助我吗?

When a user comes to my website and tries to allow publish_action permission, he will click on the 'add-to-timeline' plugin button.
Then a popup dialog appears and user will allow the required permission.
What I want to find out is that if we can specify any callback function to invoke after user allows the permission.

I know we can subscribe to 'edge.create' event through FB.Event.subscribe, but I couldn't find a similar solution for 'add-to-timeline'.
At least, it wasn't written on its document as far as I read.
Can somebody help me?

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

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

发布评论

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

评论(1

半边脸i 2024-12-14 20:59:35

您可以订阅全局事件来完成此任务。

如果您订阅 auth.loginauth.authResponseChangeauth.statusChange,它们将在用户通过 '< 授权您的应用程序后被调用a href="https://developers.facebook.com/docs/reference/plugins/add-to-timeline/" rel="nofollow">添加到时间线'。

因此,例如您可以这样做...

FB.Event.subscribe('auth.login', function(response) {
  alert('The user has just authorized your application');
});

但是我猜您想要的与我想要的相同,即在用户第一次单击“添加到时间线”后将操作添加到时间线中,并且然后在后续访问您的网站时,只需将其自动添加到时间线中即可。

要做到这一点,你会这样做......

/** put your FB.init right here **/

FB.Event.subscribe('auth.statusChange', function(response) {
  if (response.status == 'connected') {
    FB.api("/me/foobar:watch" + "?video=http://foobar.com/video/123","post",
      function(response) {
        if (!response || response.error) {
          alert("Error");
        } else {
          alert("Post was successful! Action ID: " + response.id);
        }
      });
  }  
});

You can subscribe to the global events to accomplish this.

If you subscribe to auth.login, auth.authResponseChange, or auth.statusChange they will be called after the user authorized your application via 'add-to-timeline'.

So for example you could do this...

FB.Event.subscribe('auth.login', function(response) {
  alert('The user has just authorized your application');
});

However I'm guessing what you want is the same thing that I wanted which is to have the action added to the timeline after the user clicks 'add-to-timeline' the first time and then on subsequent visits to your site just have it added to the timeline automatically.

To do that you would do this...

/** put your FB.init right here **/

FB.Event.subscribe('auth.statusChange', function(response) {
  if (response.status == 'connected') {
    FB.api("/me/foobar:watch" + "?video=http://foobar.com/video/123","post",
      function(response) {
        if (!response || response.error) {
          alert("Error");
        } else {
          alert("Post was successful! Action ID: " + response.id);
        }
      });
  }  
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文