FB not defined and prompts error

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:51:17

问题


I am a newbie in writing the facebook apps. I would like to use the fb.ui to post the message in the users wall on an apps. But when I call the following method, it prompts the error the fb not defined. I really need some help. My code is as below.

(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/zh_HK/sdk.js#xfbml=1&appId=<?=$app_id?>&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
    function postToWall(){
         FB.ui({
         method: 'feed',
         name: name,
         link: link,
         picture: picture,
         caption: caption,
         description: redemption,
         message: message
       },
       function (response) {
         if (response && response.post_id) {
           alert(response.post_id);
         } else {

         }
       });
    }


     postToWall();

来源:https://stackoverflow.com/questions/24157924/fb-not-defined-and-prompts-error

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