Loading...
 
Skip to main content

Features / Usability


You are viewing a reply to Social Login unable to auto create user

Re: Social Login unable to auto create user

This is what I've got:

Copy to clipboard
/** * Old tiki way of getting access_token using socket. Some say it faster than curl. Maybe we * need to move it to hybridauth as an alternative to curl, like guzzle? */ function getFacebookAccessToken() { 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 ////////////////////// $url = '/' . $this->graphVersion . '/oauth/access_token?client_id=' . $prefs['socialnetworks_facebook_application_id'] . '&redirect_uri=' . $this->getURL() . '&client_secret=' . $prefs['socialnetworks_facebook_application_secr'];


Unfortunately, blank screen.