访问令牌?

时间:2012-04-26 23:16:46

标签: access-token facebook-authentication facebook-access-token

我正在开发一个在Heroku上托管的PHP应用程序,而我最大的问题是没有为用户获取访问令牌以使我的应用程序完全正常工作。该应用程序适合我(因为我是一名管理员),但其他与应用程序无关的人无法让应用程序显示任何内容。我也试过使用测试用户看看它是否可行,但仍然没有运气。我很确定它与访问令牌和应用程序没有权限做这件事有关。我如何以及在何处解决此问题?

1 个答案:

答案 0 :(得分:0)

我使用

for user access_token ,其中数字是应用程序ID。


if($_SESSION['fb_135669679827333_access_token']){
$access_token = $_SESSION['fb_135669679827333_access_token'];
}

应用程序访问令牌的

我使用cURL。返回结果类似于access_token = xxxxxxxxxx 使用 - / anotherfeed / feed?$ app_access_token


$app_access_token = GetCH();
function GetCH(){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=SECRET_KEY&grant_type=client_credentials");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
if(substr($url,0,8)=='https://'){
    // The following ensures SSL always works. A little detail:
    // SSL does two things at once:
    //  1. it encrypts communication
    //  2. it ensures the target party is who it claims to be.
    // In short, if the following code is allowed, CURL won't check if the 
    // certificate is known and valid, however, it still encrypts communication.
    curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
}
$sendCH = curl_exec($ch);
curl_close($ch);
return $sendCH;
};