【问题标题】:php http facebook api GET notationphp http facebook api GET 表示法
【发布时间】:2014-11-06 20:59:57
【问题描述】:

我不理解 Facebook 文档(找到 here)中 GET 请求的这种表示法:

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

这在 apache 术语中是什么意思以及如何在 php 中编写这样的请求?我发现file_get_contentshttp_get 都需要一个网址。语法如下:

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

我可以使用其中一个或两个功能吗?我该怎么写?我正在寻找关于此的良好文档的时间。

【问题讨论】:

  • 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')
  • @Marc B:感谢您容忍初学者的问题!在网上找不到任何关于此的内容。希望这对将来的其他初学者有所帮助。
  • 你输入你的客户端ip/secret了吗?还是您确实使用了{app-id}{app-secret}
  • 成功了!谢谢你。请张贴作为答案,我会接受。

标签: php facebook facebook-graph-api get-request


【解决方案1】:

来自@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')

记得去掉 app-id 和 app-secret 中的花括号。

【讨论】:

    猜你喜欢
    • 2023-03-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-28
    • 1970-01-01
    • 2018-12-14
    • 2017-10-30
    相关资源
    最近更新 更多