1

I am developing an app in PHP hosted on Heroku, and my biggest problem is not getting access tokens for a user to get my app to fully work. The app works perfectly for me (as I am an admin), but other people who arent associated with the app cannot get the app to display anything. I also tried using test users to see if it would work, but still no luck. Im pretty sure it has to do with access tokens and the app not having permission to do its thing. How and where do I fix this?

4

1 に答える 1

0

私が使用するユーザー 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;
};
于 2012-04-27T05:53:59.490 に答える