PHP Facebook图形API搜索cURL - 没有结果 [英] PHP Facebook graph API search cURL - no results
问题描述
我有一个Facebook的图形API的问题。
我试图做一个搜索通过在Facebook上的帖子过滤关键字,但我似乎无法获取结果。
当我在浏览器中复制我的URL时,它工作正常。
I've got a problem with the facebook graph API. I'm trying to do a search through the posts on facebook filtered on a keyword, but I can't seem to fetch the results. When I copy my url in a browser, it works fine.
我认为它与我的cURL参数有关,我很新这。
I think it has something to do with my cURL parameters, i'm pretty new to this.
<?php
$keyword = $_POST['keyword'];
$graph_url = "https://graph.facebook.com/search?&type=post&locale=en_US&q=".$keyword;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $graph_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
print $result;
?>
任何人都知道这是什么问题,或任何知道不同解决方案从Facebook获取搜索结果的人。
Anyone knows what's wrong with this, or anyone who knows a different solution to fetch search results from facebook.
推荐答案
当您尝试通过HTTPS访问网站时,应关闭SSL验证或添加证书以进行验证。详情: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
As you are trying to reach site through HTTPS, you should turn off SSL verification, or add certificate to verify with. Details here: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
快速修复:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
或者您可以将网址更改为:
Or you can just change your url to:
http://graph.facebook.com/search?&type=post&locale=en_US&q=
这篇关于PHP Facebook图形API搜索cURL - 没有结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!