应用程序内的 Facebook 请求对话框

发布于 2024-11-09 16:19:48 字数 776 浏览 0 评论 0原文

我试图在画布应用程序内弹出一个请求对话框(朋友列表),但我遇到了麻烦,并且在教程上找不到任何帮助。

这里是身份验证后的代码等。有关

<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : '[**myid**]',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
</script>
<button id="send-to-many">Send to Many</button>
<div id="fb-root"></div>
<script>
document.getElementById('send-to-many').onclick = function() {
 FB.ui({
    method: 'apprequests',
    message: 'You should learn more about blabla].',
  }, Log.info.bind('send-to-many callback'));
}
</script>

如何在 FB 画布上启动 JS 的任何想法或示例吗?

I'm trying to popup a request dialog (of the list of friends) inside the canvas app, but I'm having troubles and I'm not finding any help on tutorials.

Here the code after the authentication, etc.

<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
  FB.init({
    appId  : '[**myid**]',
    status : true, // check login status
    cookie : true, // enable cookies to allow the server to access the session
    xfbml  : true  // parse XFBML
  });
</script>
<button id="send-to-many">Send to Many</button>
<div id="fb-root"></div>
<script>
document.getElementById('send-to-many').onclick = function() {
 FB.ui({
    method: 'apprequests',
    message: 'You should learn more about blabla].',
  }, Log.info.bind('send-to-many callback'));
}
</script>

any ideas or any examples of how to initiate the JS on a FB canvas?

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

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

发布评论

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

评论(2

浮世清欢 2024-11-16 16:19:48

问题是 FB.ui() 函数中的第二个参数应该是回调函数。尝试删除它并用 null 或已定义的函数或内联函数替换它。如果您确实需要调用 Log.info.bind,请确保定义该函数并包含定义脚本。现在,请尝试以下操作:

<script type="text/javascript">
document.getElementById('send-to-many').onclick = function() {
 FB.ui({
    method: 'apprequests',
    message: 'You should learn more about blabla].',
  }, function(response) {
     //Log.info.bind('send-to-many callback'));
  alert('callback called');
  })
}
</script>

Facebook 文档提供了您想要执行的操作的示例和代码。查看他们的请求文档

The problem is that the second parameter in the FB.ui() function is supposed to be a callback function. Try removing it and either replace it with null or a function that is defined or with an inline function. If you do need to call Log.info.bind, make sure the function is defined and the defining script gets included. For now, try something like:

<script type="text/javascript">
document.getElementById('send-to-many').onclick = function() {
 FB.ui({
    method: 'apprequests',
    message: 'You should learn more about blabla].',
  }, function(response) {
     //Log.info.bind('send-to-many callback'));
  alert('callback called');
  })
}
</script>

Facebook documentation has examples and code for what you are trying to do. Check their requests documentation.

旧时模样 2024-11-16 16:19:48

如果您想使用 Log.info.bind ,请将其更改为 console.log()

<script>
document.getElementById('send-to-many').onclick = function() {
 FB.ui({
    method: 'apprequests',
    message: 'You should learn more about blabla].',
  }, Log.info.bind('send-to-many callback'));
}
</script>

If you want to use the Log.info.bind , change it to console.log()

<script>
document.getElementById('send-to-many').onclick = function() {
 FB.ui({
    method: 'apprequests',
    message: 'You should learn more about blabla].',
  }, Log.info.bind('send-to-many callback'));
}
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文