我正在尝试使用https://api.facebook.com
以下工作正常:(注意graph.facebook.com)
$q = "https://graph.facebook.com/$params".$sep."access_token=$access_token";
$response = json_decode(file_get_contents($q),true);
但是
$q = "https://api.facebook.com/$params".$sep."access_token=$access_token";
$response = json_decode(file_get_contents($q),true);
只是不起作用。我尝试过curl,但我一直在方法未实施
以下代码:
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$url = "https://api.facebook.com/$params".$sep."access_token=$access_token";
echo $url;
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_URL, $url);
echo curl_exec($ch);
echo curl_errno($ch);
curl_close ($ch);
有什么想法吗?
答案 0 :(得分:0)
这样一个愚蠢的错误。我发布了工作示例:
电话:
$status = $fb->api("method/fql.query?query=".urlencode("SELECT url FROM url_like WHERE user_id = $ID")."",$access_token);
班级:
class fb
{
public function api($params, $access_token)
{
try
{
$q = "https://api.facebook.com/$params?format=json-strings&access_token=$access_token";
$response = json_decode(file_get_contents($q),true);
if ($response->error->message != null)
throw new Exception($response->error->message);
else
return $response;
}
catch (Exception $e)
{
return ("<b>Error:</b> " . $e->getMessage());
}
}
}
对于每个不想使用facebok php sdk的人。