2014-09-12 86 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和应用程序秘密的花括号。