Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中获取Facebook页面喜好(FQL折旧后)_Php_Facebook_Facebook Graph Api_Facebook Fql - Fatal编程技术网

在PHP中获取Facebook页面喜好(FQL折旧后)

在PHP中获取Facebook页面喜好(FQL折旧后),php,facebook,facebook-graph-api,facebook-fql,Php,Facebook,Facebook Graph Api,Facebook Fql,我曾经能够在Facebook上通过一个FQL查询URL获得页面喜好。但截至上周,他们关闭了它。要求使用他们的SDK或API,但我的系统会扫描我用户的facebook页面,并显示他们喜欢的页面 如果我使用SDK或API,有什么方法可以解决这个问题吗。我需要为每个页面的每个请求一个应用程序 谢谢 注: 我尝试使用头和用户代理来处理文件\u get\u contents()&在一个手机请求上尝试,但没有成功 代码: 结果: 我不知道为什么这个问题被否决了。以前,我们使用fql获得like/股份计数,f

我曾经能够在Facebook上通过一个FQL查询URL获得页面喜好。但截至上周,他们关闭了它。要求使用他们的SDK或API,但我的系统会扫描我用户的facebook页面,并显示他们喜欢的页面

如果我使用SDK或API,有什么方法可以解决这个问题吗。我需要为每个页面的每个请求一个应用程序

谢谢

注: 我尝试使用头和用户代理来处理
文件\u get\u contents()
&在一个手机请求上尝试,但没有成功

代码:

结果:


我不知道为什么这个问题被否决了。以前,我们使用fql获得like/股份计数,fql在2016年8月7日之后折旧。我们可以使用这个技巧来获得相同的计数

只需向facebook发出一个curl请求&解析结果

   $domain='stackoverflow.com';  
   $protocol='http://';  
   $orgin=$protocol.$domain.'/';
   $url='http://stackoverflow.com';

   $param=array('action'=>'like','app_id'=>'','channel'=>'http://staticxx.facebook.com/connect/xd_arbiter/r/lUqP5iIjiw6.js?version=42#cb=f178d9075b06a6a',
   'domain'=>$domain,'orgin'=>$orgin,'relation'=>'parent.parent','container_width'=>0,'href'=>$url,'layout'=>'button_count','locale'=>'en_GB','sdk'=>'joey',
   'share'=>false,'show_faces'=>true,'size'=>'large');

   $fb_url='https://www.facebook.com/v2.6/plugins/like.php?';

   $ch= curl_init();
   $options=array( 
   CURLOPT_URL => $fb_url.http_build_query($param),
   CURLOPT_FRESH_CONNECT => 1,
   CURLOPT_RETURNTRANSFER => 1, 
   CURLOPT_FORBID_REUSE =>1,
   CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 5.01;Windows NT 5.0)",
   CURLOPT_SSL_VERIFYHOST=> 0,
   CURLOPT_SSL_VERIFYPEER=> 0, 
   CURLOPT_REFERER=>$orgin,
   CURLOPT_CONNECTTIMEOUT=> 10,
   CURLOPT_TIMEOUT=>40
  );

  curl_setopt_array($ch,$options);
  $fb_html=curl_exec($ch);

  if(curl_errno($ch)>0){ #checks any curl error
   $fbc='';
  }else{ 
   $fb_html=preg_replace('/\s+/', '',$fb_html);
   preg_match('/<span[^>]*id="u_0_3">(.*?)<\/span>/sm',$fb_html,$count);
   $fbc=$count[1];  
  }

  curl_close($ch);
  echo "Like count:$fbc";
$domain='stackoverflow.com';
$protocol='http://';
$orgin=$protocol.$domain.'/';
$url='1http://stackoverflow.com';
$param=array('action'=>'like','app_id'=>'','channel'=>'http://staticxx.facebook.com/connect/xd_arbiter/r/lUqP5iIjiw6.js?version=42#cb=f178d9075b06a6a',
'domain'=>$domain,'orgin'=>$orgin,'relation'=>'parent.parent','container\u width'=>0,'href'=>$url,'layout'=>'button\u count','locale'=>'en\u GB','sdk'=>'joey',
‘share’=>false、‘show_faces’=>true、‘size’=>large’;
$fb_url='1https://www.facebook.com/v2.6/plugins/like.php?';
$ch=curl_init();
$options=数组(
CURLOPT_URL=>$fb_URL.http_build_query($param),
CURLOPT_FRESH_CONNECT=>1,
CURLOPT_RETURNTRANSFER=>1,
CULLOPT_禁止重复使用=>1,
CURLOPT_USERAGENT=>“Mozilla/4.0(兼容;MSIE 5.01;Windows NT 5.0)”,
CURLOPT_SSL_VERIFYHOST=>0,
CURLOPT_SSL_VERIFYPEER=>0,
CURLOPT_REFERER=>$orgin,
CURLOPT_CONNECTTIMEOUT=>10,
CULLOPT_超时=>40
);
curl_setopt_数组($ch$options);
$fb_html=curl_exec($ch);
如果(curl_errno($ch)>0,{检查任何curl错误
$fbc='';
}否则{
$fb_html=preg_replace('/\s+/','','$fb_html);
preg_match('/]*id=“u_0_3”>(.*?)/sm',$fb_html,$count);
$fbc=$count[1];
}
卷曲关闭($ch);
echo“类似计数:$fbc”;

查看此帖子以了解详细解释:

对于每个用户,您必须获得访问令牌才能通过facebook api获取用户信息。从api响应中,你现在可以得到你想要的。“但是我的系统从我的用户那里扫描facebook页面”-未经facebook事先书面同意就删除他们的页面是违反他们的ToS的,所以你一直在做的事情是不被允许的。使用他们的API是正确的方法。
   $domain='stackoverflow.com';  
   $protocol='http://';  
   $orgin=$protocol.$domain.'/';
   $url='http://stackoverflow.com';

   $param=array('action'=>'like','app_id'=>'','channel'=>'http://staticxx.facebook.com/connect/xd_arbiter/r/lUqP5iIjiw6.js?version=42#cb=f178d9075b06a6a',
   'domain'=>$domain,'orgin'=>$orgin,'relation'=>'parent.parent','container_width'=>0,'href'=>$url,'layout'=>'button_count','locale'=>'en_GB','sdk'=>'joey',
   'share'=>false,'show_faces'=>true,'size'=>'large');

   $fb_url='https://www.facebook.com/v2.6/plugins/like.php?';

   $ch= curl_init();
   $options=array( 
   CURLOPT_URL => $fb_url.http_build_query($param),
   CURLOPT_FRESH_CONNECT => 1,
   CURLOPT_RETURNTRANSFER => 1, 
   CURLOPT_FORBID_REUSE =>1,
   CURLOPT_USERAGENT => "Mozilla/4.0 (compatible; MSIE 5.01;Windows NT 5.0)",
   CURLOPT_SSL_VERIFYHOST=> 0,
   CURLOPT_SSL_VERIFYPEER=> 0, 
   CURLOPT_REFERER=>$orgin,
   CURLOPT_CONNECTTIMEOUT=> 10,
   CURLOPT_TIMEOUT=>40
  );

  curl_setopt_array($ch,$options);
  $fb_html=curl_exec($ch);

  if(curl_errno($ch)>0){ #checks any curl error
   $fbc='';
  }else{ 
   $fb_html=preg_replace('/\s+/', '',$fb_html);
   preg_match('/<span[^>]*id="u_0_3">(.*?)<\/span>/sm',$fb_html,$count);
   $fbc=$count[1];  
  }

  curl_close($ch);
  echo "Like count:$fbc";