使用PHP并希望在PHP中获取Facebook访问令牌(无SDK)

使用PHP并希望在PHP中获取Facebook访问令牌(无SDK),php,json,facebook,Php,Json,Facebook,我的代码如下: //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

我的代码如下:

//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);
我没有使用PHPSDK(Facebook),它不工作。。。。
我在浏览器中运行相同的链接,它可以返回JSON格式的访问令牌。

我假设您在这里找到了URL:


不要忘记
code
参数。当用户授权你的应用程序时,你就会得到它。这就是您需要的:

描述实际发生的情况以及调试输出的结果,而不仅仅是“不起作用”。如果您只需要一个应用程序访问令牌-您不需要为此进行API调用,则应用程序id和应用程序机密的组合以及介于两者之间的管道符号(
id | secret
)始终可以用作应用程序访问令牌。感谢您的建议。