response.authResponse为null [英] response.authResponse is null

查看:205
本文介绍了response.authResponse为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  FB.getLoginStatus(function(response){
if(response.status ==='connected'){
var user_id = response.authResponse.userID;
var page_id =app_id;
var fql_query =SELECT uid FROM page_fan WHERE page_id =+ page_id +和uid =+ user_id;
var the_query = FB.Data.query(fql_query);
the_query.wait(function(rows){
if (rows.length == 1&& rows [0] .uid == user_id){
alert(喜欢的页面);
}
else {
alert(不喜欢);
}
});
}
else if(response.status ==='not_authorized'){

}
else
{
alert(not logged in);
}
});

我得到的值为 response.authResponse 在第一个if部分ie在 if(response.status ==='connected'){} 部分,但我得到 response.authResponse null in else if(response.status ==='not_authorized'){} part,



有人有任何想法吗?



请帮助我。

解决方案

为了能够调用图形以获得喜好,您需要让用户使用 user_likes 权限添加/验证您的应用程序,然后可以阅读。所以在上面的代码中,当它们落入两个 else 案例之一时,调用FB.login()(或在页面上显示fb登录按钮)。



如果您不想强制用户添加/验证您的应用程序,那么您需要将应用程序配置为页面选项卡应用程序,然后可以抓取signed_request(https://developers.facebook.com/docs/authentication/signed_request/)并解码,提供访问权限,知道用户是否喜欢您的应用程序是页面标签的页面。


i have write following code to check the login status of facebook.

    FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
    var user_id = response.authResponse.userID;  
    var page_id = "app_id"; 
    var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
    var the_query = FB.Data.query(fql_query);
    the_query.wait(function(rows) {
                 if (rows.length == 1 && rows[0].uid == user_id) {
                    alert("liked the page");
                 }
                 else {
                    alert("not liked ");
                 }
            });
  }
  else if (response.status === 'not_authorized') {

  }
  else
  {
    alert("not logged in");
  }
});

i am getting the value for response.authResponse in first if section i.e. in if (response.status === 'connected') {} part but i'm getting response.authResponse null in else if (response.status === 'not_authorized') {} part,

do anyone have any idea about it??

Please help me.

解决方案

To be able to call the graph to get likes, you will need to have the user add/authenticate your app with the user_likes permissions and then you can read it. So in your code above, when they fall into either of the two else cases, call FB.login() (or display the fb login button on the page).

If you don't want to force the user to add/authenticate your app, then you will need to configure your app as a Page Tab app and then you can grab the signed_request (https://developers.facebook.com/docs/authentication/signed_request/) and decode that providing access to know if the user has liked the page that your app is a page tab of.

这篇关于response.authResponse为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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