2011-09-04 32 views
1
Warning: file_get_contents(https://graph.facebook.com/me?access_token=) [function.file-    get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request in /var/www/dsg/signed_request.php on line 25 

我已經確認並在我的php.ini設置了allow_url_fopen到上還確保了allow_url_fopen是,當我跑的phpinfo上( );.我仍然收到上面列出的錯誤。有沒有人知道這是否能夠以某種方式工作?也許有一些轉換爲另一種?警告:的file_get_contents(https://graph.facebook.com/me?access_token=)

回答

1

您可以使用curl,它實際上應該用於網絡請求,而不是file_get_contents。我不知道爲什麼Facebook開始使用那個函數的例子。 Curl具有錯誤處理功能,如果你願意的話,它會遵循重定向,所以你可以確切知道什麼是攻擊。

+0

我現在用的捲曲。現在我得到一個錯誤。必須使用活動訪問令牌來查詢有關當前用戶的信息。 – Giuseppe

+0

所以你溝通得很好。您需要開始一個會話以獲取訪問令牌以包含在URL中。 –

0

您可以創建自己的一條線的功能這樣

function viacurl($location){ 
    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_URL, $location); 
    curl_setopt($ch, CURLOPT_HEADER, false); 

    $out=curl_exec($ch); 

    curl_close($ch); 

    return rtrim($out,1); 
} 

而且使用這樣的:

$response = viacurl($url);