facebook-> getUser返回0 [英] facebook->getUser returns 0

查看:81
本文介绍了facebook-> getUser返回0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Facebook粉丝专页,我想检查用户是否访问该页面LIKEES该页面以显示内容。当我以管理员身份登录时,当另一个帐户访问该页面时,该工作正常。 facebook-> getUser()始终返回0

I have a Facebook fan page and I want to check if the user visiting the page LIKES the page in order to show the content. It works when I am logged in as the administrator but when another account visits the page the facebook->getUser() always return 0

require 'src/facebook.php';

$facebook = new Facebook(array(
  'appId' => 'ID',
  'secret' => 'HASH',
  'cookie' => true,
));

$user = $facebook->getUser();

//Page id

$page = '215010578537112';


$likeID = $facebook->api(array( 'method' => 'fql.query', 'query' =>
'SELECT uid  FROM page_fan WHERE uid =' . $user . 'AND page_id =' .$page ));

if ( $likeID ) {

}else{

}


推荐答案

由于这是粉丝专页,您不需要调用FQL查询,因为FQL查询要求用户具有首先授权您的申请。 Facebook将发送一个signed_request post参数到您的iframe粉丝专页。请参阅此答案,了解如何解码signed_request参数并检查以查看如果他们是你的页面的粉丝或不。

Since this is a fan page, you don't need to call an FQL query, since an FQL query requires that the user has first authorized your application. Facebook will send a signed_request post parameter to your iframe fan page. See this answer on how to decode that signed_request parameter and check to see if they are a fan of your page or not.

这篇关于facebook-> getUser返回0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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