這是一個簡單的curl函數,用於facebook sdk。不要忘記將路徑更改爲fb_ca_chain_bundle.crt
。
function curl($url, $certificate = false) {
$c = curl_init($url);
curl_setopt($c, CURLOPT_HTTPGET, true);
curl_setopt($c, CURLOPT_FRESH_CONNECT, true);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($c, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt ($c, CURLOPT_CAINFO, dirname(__FILE__) . '/sdk/fb_ca_chain_bundle.crt');
$output = curl_exec($c);
if ($output === false) {
curl_close($c);
return false;
}
curl_close($c);
return $output;
}
這裏是方法調用,以獲得長壽命令牌:
§token = curl('https://graph.facebook.com/oauth/access_token?client_id='.
$app_id.'&client_secret='.
$app_secret.'&grant_type=fb_exchange_token&fb_exchange_token='.
$api->getAccessToken());
你應該看看到SDK https://developers.facebook.com/docs/reference/php/ – baloo
沒有關於如何檢索長壽命令牌。 –