[英]Access tokens?
我正在用Heroku托管的PHP開發一個應用程序,最大的問題是沒有為用戶獲取訪問令牌以使我的應用程序正常運行。 該應用程序非常適合我(我是管理員),但是與該應用程序相關聯的其他人無法讓該應用程序顯示任何內容。 我還嘗試使用測試用戶來查看它是否可以運行,但還是沒有運氣。 我非常確定它與訪問令牌有關,並且該應用沒有權限執行其操作。 如何以及在哪里修復此問題?
我使用的用戶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;
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.