English 中文(简体)
FB.api不从事任何工作
原标题:FB.api not working every time

我是在Facebook Javascript SDK的。 我正试图利用这一机会提出申请。 但是,在篡改“FB.api”方法时,却很难 l。 我的“FB.api”方法有时没有适当运作。 有时会做出反应(我只是得到答复,姓名),而其他时间也不会适当援引。

window.fbAsyncInit = function() {
FB.init({
  appId      :  my_app_id , // App ID
  status     : true, // check login status
  cookie     : true, // enable cookies to allow the server to access the session
  oauth      : true, // enable OAuth 2.0
  xfbml      : true  // parse XFBML
});
FB.getLoginStatus(function(response) {
  if (response.authResponse) {
   alert( user is: +response.status); 
   userId = response.authResponse.userID;
   FB.api( /me ,function(response) {
   alert( Inside FB.api function );
   document.getElementById("userInfo").innerHTML =  Welcome <img src="https://graph.facebook.com/ + response.id +  /picture" style="margin-right:5px"/>  +response.name +  ! ;
    });
    }
});
};

其他方法FB.ui和FB.get CarloinStatus和Facebook,如纽芬兰,正在按预期进行工作,但只有FB.api公司没有像其他方法一样无缝工作。 不是为什么? 请帮助我解答这一问题。

问题回答

我有同样的问题。 这一答复向我指出了正确的方向:

FB.api在FB.init之后被叫右时没有工作。

为了解决我的问题,我不得不赞同正确的事件。 在我的案件中,这是 au。 FB.init之后的变化

FB.Event.subscribe( auth.authResponseChange , function(){
    FB.api( /me ,function(r){
    console.log(r.id);
     if (!r || r.error) {
        alert( Error occured );
      } else {
        alert(r.name);
      }         
    });
});

That code works fine for me, but you might want to try renaming your response variables. Inside the FB.api callback, you actually have two response variables which will undoubtedly cause problems. Try changing them and see if you get different results.

FB.getLoginStatus(function(loginResponse) {
  if (loginResponse.authResponse) {
   alert( user is: +loginResponse.status); 
   userId = loginResponse.authResponse.userID;
   FB.api( /me ,function(apiResponse) {
   alert( Inside FB.api function );
   document.getElementById("userInfo").innerHTML =  Welcome <img src="https://graph.facebook.com/ + apiResponse.id +  /picture" style="margin-right:5px"/>  +apiResponse.name +  ! ;
    });
    }
});

Its possible there is something else on your page affecting this. Do you have a link to your page?

我有同样的问题。 英国广播公司在我处的某个时候刚刚停止了无声的工作。 我注意到,由于OMM操纵:

<div id="fb-root"></div>

重复或任何东西。 我们应该检查这一点。 它像Johan Strydom一样。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签