使用PHP和想在PHP Facebook的访问令牌(无SDK)
问题描述:
我的如下代码:使用PHP和想在PHP Facebook的访问令牌(无SDK)
//Tie it all together to construct the URL
$url = "https://graph.facebook.com/oauth/access_token?client_id=[ID]&client_secret=[key]&grant_type=client_credentials";
//Make the API call
$result = file_get_contents($url);
//Decode the JSON.
$decoded = json_decode($result, true);
//Dump it out.
var_dump($decoded);
var_dump($result);
我不使用PHP SDK(脸谱)和它不工作
.. .. 我在浏览器中运行相同的链接,它可以在JSON中返回访问令牌。
答
我假设你发现这个网址:https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow
不要忘有关code
参数。你得到它时,用户授权你的应用程序。这就是你需要的:https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#login
+0
谢谢你的建议。 –
描述实际发生的情况以及从调试输出中得到的结果 - 而不仅仅是“不起作用”。如果您只需要一个应用程序访问令牌 - 您不需要为此进行API调用,则应用程序ID和应用程序密钥与之间的管道符号('id | secret')的组合总是作为应用程序访问令牌。 – CBroe