Loading...
 
Features / Usability

Features / Usability


Re: Re: Social Login unable to auto create user

posts: 400

Please paste the code between "START NEW CODE" and "END NEW CODE" between the lines indicated that should come before and after the new block (it's around line 199 in lib/socialnetworkslib.php). Let me know if that works and please let me know any error messages you receive.

*****************

global $prefs, $user;
$userlib = TikiLib::lib('user');

// code parameter provided by Facebook is already in the url
///////////////// START NEW CODE //////////////////////
$url = '/' . $this->graphVersion . '/oauth/access_token?client_id='
. $prefs['socialnetworks_facebook_application_id'] . '&redirect_uri=' . $this->getURL() . '&client_secret=' . $prefs['socialnetworks_facebook_application_secr'];
//try socket first
$fp = fsockopen('ssl://graph.facebook.com', 443, $errno, $errstr);
if ($fp) {
$request = "GET $url HTTP/1.1\r\n" .
"Host: graph.facebook.com\r\n" .
"Accept: */*\r\n" .
"Expect: 100-continue\r\n" .
"Connection: close\r\n\r\n";

fputs($fp, $request);
$ret = '';
while (! feof($fp)) {
$ret .= fgets($fp, 128);
}
fclose($fp);
$ret = preg_split('/(\r\n\r\n|\r\r|\n\n)/', $ret, 2);
$ret = $ret[1];
} else {
// try cURL
$url = 'https://graph.facebook.com' . $url;
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$ret = curl_exec($ch);
curl_close($ch);
}
$json_decoded_ret = json_decode($ret, true);
////////// END NEW CODE //////////////////////
if (isset($json_decoded_ret['access_token']) || substr($ret, 0, 13) == 'access_token=') {