我想在PHP脚本(id和名称)中获取有关用户的一些基本信息。图形API:如何抓取当前用户的信息?
我曾尝试以下方法:
$retrieve = curl_init("https://graph.facebook.com/me?access_token=$accesstoken");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($retrieve, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($retrieve);
curl_close($retrieve);
和
$user = json_decode(file_get_contents(
"https://graph.facebook.com/me?access_token=$accesstoken"))->me;
卷曲方法(前)只是超时。 file_get_contents(后者)方法根本不返回任何东西...
什么可能导致这种情况?我正确使用cURL吗?
你检查一下file_get_contents()函数返回的信息没有json_decode()调用和 - > me操作符? – 2010-10-23 23:10:40
为什么不使用Facebook PHP SDK来做到这一点? http://github.com/facebook/php-sdk – 2010-10-23 23:10:49
@Eran:是的,它根本没有任何回报。这完全是空的。 @Nathan:我现在没有使用SDK,我需要先手动执行此操作。我不明白为什么这不起作用... – 2010-10-23 23:18:11