在阅读了有关stackoverflow的所有内容和问题后,我仍然没有得到它的工作 代码:
<?php
include_once 'debug/debug.php';
if (isset($_GET["username"])) {
$appId="XXX";
$appSecret="YYY";
$code = $_GET["code"];
echo "Code: <br>" . $code . "<hr>";
//Optain App Token!
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL,
"https://graph.facebook.com/oauth/access_token?client_id=" . $appId .
"&client_secret=". $appSecret.
"&grant_type=client_credentials");
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
$access_token = explode("=", $result)[1];
echo $access_token;
//Option further Information
$ch = curl_init ();
//curl_setopt ( $ch, CURLOPT_URL, "https://graph.facebook.com/me?access_token=" . $code);
curl_setopt ( $ch, CURLOPT_URL, "https://graph.facebook.com/debug_token?input_token=" . $code . "&access_token=" . $access_token);
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
}
?>
答案是:
{ “数据”:{ “错误”:{ “消息”: “格式错误的接入令牌AQB6hhoeZJ1SR5RqtPp-iEDEd1Fg38GV95tW2YrVR9EfK6Y8H7QgcrSr8uagegIpKa4rPI7z4qSw45COZZL1XMDUuigsrBLNg5NKXl2bd9GPYC1Qo5peH81mGqP6LqK-orL3uqCH3Bta3kHOGp76RmK8p391soS47ZR8WE5gNx6s35qctgoHuWE47R0w93GeNglRxu2IUtVsGhZgyGiA9l12BMq9NX5O9Kcp2DupVqWs67Vnqz8MntrTx-AzbFhdHrYtWOhmFb8WybrT3ZuGqETZEAGc9JOTuhiHJW3Elp_rE7IWA50MIWsAaqM77fuI1Go”, “代码”:190}, “is_valid”:假}}
来自facebook的登录名为$ uri代表:$
https://www.facebook.com/dialog/oauth?client_id=APP_ID&redirect_uri=http://www.mineforce.de/ms/fblogin.php?username=USERNAME
我不明白为什么访问令牌应该是错误的,因为我们通过Facebook本身得到它。
在这里可以找到外包等:
http://www.mineforce.de/ms/fblogin.php?username=phibedy&code=AQB6hhoeZJ1SR5RqtPp-iEDEd1Fg38GV95tW2YrVR9EfK6Y8H7QgcrSr8uagegIpKa4rPI7z4qSw45COZZL1XMDUuigsrBLNg5NKXl2bd9GPYC1Qo5peH81mGqP6LqK-orL3uqCH3Bta3kHOGp76RmK8p391soS47ZR8WE5gNx6s35qctgoHuWE47R0w93GeNglRxu2IUtVsGhZgyGiA9l12BMq9NX5O9Kcp2DupVqWs67Vnqz8MntrTx-AzbFhdHrYtWOhmFb8WybrT3ZuGqETZEAGc9JOTuhiHJW3Elp_rE7IWA50MIWsAaqM77fuI1Go#=
其次,我不明白为什么fb将# = 放在令牌的末尾
干杯:)
答案 0 :(得分:0)
代码工作,我在java中调用了一些调试代码,所以我认为被称为的代码不被称为:) 我花了4个小时找到它,但无论如何。如果你一步一步地按照facebook-tut一切都应该工作正常。 干杯:)