FB.api不是函数 [英] FB.api is not a function

查看:120
本文介绍了FB.api不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把所有的帖子在用户墙。我有一个例子运行连接到FB还好,但是当我尝试使用FB.api来获取用户名(我绝对连接成功),我得到 FB.api不是一个函数。一些搜索发现这表明我使用了错误的API链接,但是当我尝试(这似乎用同样的方法来连接)一切萤火NET小组说,它成功地加载,没有错误。 。 。没有任何反应都没有。

I'm trying to pull all of the posts on a users wall. I got an example running that connects to FB okay, but when I try to use FB.api to get the username (I am definitely successfully connected), I get FB.api is not a function. Some searching found this which suggests that I'm using the wrong API link, but when I try the new one (which seems to connect using the same method) everything firebug NET panel says it loads successfully, there are no errors. . . nothing happens at all.

下面是code(更换 http://connect.facebook.net/ EN_US / all.js的链接http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php 为code的工作,直到我提到的错误):

Here is the code (replace the http://connect.facebook.net/en_US/all.js link with http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php for the code to work up until the error I mentioned):

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
<script type="text/javascript">
function grab(){
FB.api('/me', function(response) {
  alert(response.name);
  });
}
function update_user_box() {
var user_box = document.getElementById("user");
user_box.innerHTML =
"<div>"
+ "<fb:profile-pic uid='loggedinuser' facebook-logo='true'></fb:profile-pic>"
+ " Welcome, <fb:name uid='loggedinuser' useyou='false'></fb:name>"
+ "</div>"
+ "<a href=\"javascript:grab()\">try me</a>";
FB.XFBML.Host.parseDomTree();
}
</script>
</head>
<body>


<div id='user'><fb:login-button onlogin="update_user_box();"></fb:login-button></div>
<br><br>

<div id="fb-root"></div>
<script type="text/javascript">
FB.init("b07e858317c9069d450023b7500b4511", "xd_receiver.htm", {"ifUserConnected": update_user_box});

</script>
</body>
</html>

感谢任何及所有帮助!

thanks for any and all help!

推荐答案

我猜你没有正确intializing。我有类似的问题......这是我不清楚哪一个是OAuth2.0的和FB-连接。这似乎令人困惑。我跟着例子(如下图),它为我工作。请参见这里

I guess you are not intializing correctly. I had similar issues... it was not clear to me which one is oAuth2.0 and which FB-Connect. It seemed confusing. I followed the example (below), it worked for me. See here

<div id="fb-root"></div>
 <script src="http://connect.facebook.net/en_US/all.js"></script>
 <script>
   FB.init({
     appId  : 'YOUR APP ID',
     status : true, // check login status
     cookie : true, // enable cookies to allow the server to access the session
     xfbml  : true  // parse XFBML
   });
 </script>

希望这有助于。

在一个侧面说明,你可能需要延长的访问权限publish_stream,read_stream。你应该参考这里

On a side note, you might need extended permission to access publish_stream, read_stream. You should refer here

这篇关于FB.api不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆