-1
我試圖在我的Linux服務器上使用cURL從Facebook獲取訪問令牌時出現問題。在我的Windows機器上,當我在XAMPP下運行PHP時,一切正常,但在Linux中卻不行。在Linux服務器上使用curl獲取Facebook的訪問令牌
我已經在我的Linux服務器上安裝了cURL,現在正在嘗試使用它,但它不返回任何信息。
我的代碼如下:
$url = "https://graph.facebook.com/oauth/access_token?client_id=278313225526998&redirect_uri=thejunction.africanbank.net/baobab/baobab.php&client_secret=$app_secret&code=$code";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: graph.facebook.com'));
$access_token = curl_exec($ch);
curl_close($ch);
echo "access is: ".$access_token;
可有人請讓我知道我可能是錯在這裏做什麼?它給我的錯誤:
An error occured while fetching the URI
我使用
$url = 'http://www.stackoverflow.com'; //curl script to get content of given url $ch = curl_init(); // set the target url curl_setopt($ch, CURLOPT_URL,$url); // request as if Firefox curl_setopt($ch, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15")); curl_setopt($ch, CURLOPT_NOBODY, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result= curl_exec ($ch); curl_close ($ch); echo "result is".$result;
也試過,這讓我
An error occured while fetching the URI. Please retry.
,在我的php.ini文件捲曲啓用了一個錯誤,請參閱圖片
什麼可能是問題的傢伙?請幫幫我。
感謝 唐納德
這僅僅是發生了,當我嘗試了一個錯誤在此格式化此問題。 –
@Dee在這種情況下,其他參數有問題 – genesis
哈哈,我不知道有什麼不對勁,我只是不知道那個問題在哪裏。 –