मुझे समस्या मिली है। ऐसा इसलिए है क्योंकि एसडीके 3.2.2। (एपीआई संस्करण 2.3 के लिए Changelog से) फेसबुक अद्यतन के लिए:
[OAuth पहुंच टोकन] प्रारूप - https://www.facebook.com/v2.3/oauth/access_token की प्रतिक्रिया स्वरूप लौट आए हैं जब आप अब एक ACCESS_TOKEN के लिए एक कोड का आदान-प्रदान मान्य JSON लौटने के बजाय जा रहा इनकोडिंग यूआरएल। इस प्रतिक्रिया का नया प्रारूप {"access_token" है: {TOKEN}, "token_type": {TYPE}, "expires_in": {TIME}}। आरएफसी की धारा 5.1 के साथ संगत होना करने के लिए हम इस अद्यतन बनाया 6749.
लेकिन एसडीके एक सरणी के रूप में प्रतिक्रिया पहचान (getAccessTokenFromCode समारोह में) है:
$response_params = array();
parse_str($access_token_response, $response_params);
if (!isset($response_params['access_token'])) {
return false;
}
return $response_params['access_token'];
इस उपयोगकर्ता पहुंच टोकन प्राप्त नहीं होगा सही ढंग से, और आप उपयोगकर्ता का डेटा नहीं प्राप्त कर सकते हैं। तो आपको जेसन के रूप में डेटा को पार्स करने के लिए इस फ़ंक्शन को अपडेट करना चाहिए:
$response = json_decode($access_token_response);
if (!isset($response->access_token)) {
return false;
}
return $response->access_token;
तब सभी कार्य सामान्य रूप से काम करेंगे।
साथ ही, आपको setExtendedAccessToken()
के समान परिवर्तन करने चाहिए। अन्यथा, आपका ऐप एक्सेस टोकन का विस्तार करने में सक्षम नहीं होगा। नीचे दिया गया कोड दर्शाता है कि फ़ंक्शन को अपग्रेड कैसे करें।
/**
* Extend an access token, while removing the short-lived token that might
* have been generated via client-side flow. Thanks to http://bit.ly/ b0Pt0H
* for the workaround.
*/
public function setExtendedAccessToken() {
try {
// need to circumvent json_decode by calling _oauthRequest
// directly, since response isn't JSON format.
$access_token_response = $this->_oauthRequest(
$this->getUrl('graph', '/oauth/access_token'),
$params = array(
'client_id' => $this->getAppId(),
'client_secret' => $this->getAppSecret(),
'grant_type' => 'fb_exchange_token',
'fb_exchange_token' => $this->getAccessToken(),
)
);
}
catch (FacebookApiException $e) {
// most likely that user very recently revoked authorization.
// In any event, we don't have an access token, so say so.
return false;
}
if (empty($access_token_response)) {
return false;
}
//Version 2.2 and down (Deprecated). For more info, see http://stackoverflow.com/a/43016312/114558
// $response_params = array();
// parse_str($access_token_response, $response_params);
//
// if (!isset($response_params['access_token'])) {
// return false;
// }
//
// $this->destroySession();
//
// $this->setPersistentData(
// 'access_token', $response_params['access_token']
//);
//Version 2.3 and up.
$response = json_decode($access_token_response);
if (!isset($response->access_token)) {
return false;
}
$this->destroySession();
$this->setPersistentData(
'access_token', $response->access_token
);
}
v2.3 के साथ, आपको अभी भी सभी फ़ील्ड मिलना चाहिए। V2.4 से, आपको स्पष्ट रूप से उन फ़ील्ड के लिए पूछना होगा जिन्हें आप चाहते हैं, http://stackoverflow.com/a/32585470/1427878 – CBroe
@CBroe धन्यवाद, मैं इसे बाद में देखूंगा :) –
बनाने के हित में यह उत्तर अधिक खोज योग्य है, इस समस्या के कारण मुझे जो त्रुटि संदेश मिल रहा था, "वर्तमान उपयोगकर्ता के बारे में जानकारी पूछने के लिए एक सक्रिय पहुंच टोकन का उपयोग किया जाना चाहिए।" – rinogo