2014-09-12 87 views
0

我不明白這個符號對於Facebook的文檔中的GET請求(發現here):PHP進行HTTP Facebook的API GET符號

GET /oauth/access_token? 
    client_id={app-id} 
    &client_secret={app-secret} 
    &grant_type=client_credentials 

這是什麼意思在Apache中的條款以及如何我寫這樣的請求在PHP中?我找到了需要url的file_get_contentshttp_get。語法如下:

$response = http_get("http://www.example.com/", array("timeout"=>1), $info); 
$homepage = file_get_contents('http://www.example.com/') 

我可以使用這些函數中的一個或兩個?我會如何寫它?我有一段時間在找這方面的好文檔。

+1

'GET/foo'就是實際的http請求的樣子,而且如果你有'http:// example.com/foo',瀏覽器會做什麼。他們也將其分成多行以便易讀,就這些了。 – 2014-09-12 16:06:23

+0

Gotcha。所以我可以這樣發送請求:'file_get_contents('https://graph.facebook.com/oauth/access_token?client_id= {app-id}&client_secret = {app-secret}&grant_type = client_credentials')' – sterfry68 2014-09-12 16:11:09

+0

幾乎, 對。 – 2014-09-12 16:11:29

回答

0

從@Marc B:

GET/foo是實際的http請求只是個什麼樣子,而且是如果你有http://example.com/foo你的瀏覽器會做什麼。他們也將其分成多行以便易讀,就這些了。

這工作:

file_get_contents('https://graph.facebook.com/oauth/access_token?client_id={app‌​-id}&client_secret={app-secret}&grant_type=client_credentials') 

記得刪除應用ID和應用程序祕密的花括號。