1

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

+0

你可以发布你正在使用,让您的access_tokens请不要包括你的密钥的代码? – 2012-04-26 23:20:42

+0

我不认为我甚至可以在我的代码中的任何地方获得访问令牌。 – 2012-04-26 23:31:04

+1

我应该在哪里设置访问令牌? – 2012-04-26 23:40:05

回答

0

用户access_token我使用,其中数字是应用程序ID。


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

应用程序访问令牌我使用卷曲。返回的结果是一样的access_token = XXXXXXXXXX 使用像 -/anotherfeed /养活$ 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; 
};