Using Like Button and FB.ui (apprequests) On the Same Page Conflicts

旧时模样 提交于 2019-12-25 03:59:08

问题


I've ran into a problem with a canvas app. If the code for the Like button is enabled, the FB.ui call 'apprequests' gives an error. If I comment out the Like button, its back to normal. Calls with 'stream.publish' work normally tho.

My Init code:

FB.init({
  appId  : '12345',
  status : true,
  cookie : true,
  xfbml  : true,
  channelUrl : '/channel.html',
  oauth  : true
});

The code for the Like button, generated with the FB tool:

<div style="padding-left:177px">
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=12345";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="http://www.facebook.com/apps/application.php?id=12345" data-send="false" data-width="450" data-show-faces="false" data-colorscheme="dark"></div>
</div>

The FB.ui call:

FB.ui(
  {
    method: "apprequests",
    display: "iframe",
    message: "You have to check this out!"
  },
  function(response) {
    if (response && response.request_ids) {
      $.post("response.php", { rid: response.request_ids, data: data }, function(result) {
      });
    }
  }
);

The Error users get when the FB.ui is called:

API Error Code: 102
API Error Description: Session key invalid or no longer valid
Error Message: Iframe dialogs must be called with a session key

Any help is appreciated!


回答1:


You have to pass a valid access_token when using the 'iframe' display method per: https://developers.facebook.com/docs/reference/dialogs/




回答2:


just remove display: "iframe", worked for me. it will still show in an iframe, but without error. don´t ask my why, with 1:1 the same app settings it works WITH the display value in another app of mine...



来源:https://stackoverflow.com/questions/8110026/using-like-button-and-fb-ui-apprequests-on-the-same-page-conflicts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!