Loading...
 
Features / Usability

Features / Usability


Re: Social Login unable to auto create user

posts: 400

Try placing those 3 lines after this line (around line 204):

$fp = fsockopen('ssl://graph.facebook.com', 443, $errno, $errstr);

And if you get a blank screen, try those 3 lines before that line. If you don't get a blank page, then please replace the entire block of code from the line above to where about where we stopped before with the latest new code block, so that you have this:

// code parameter provided by Facebook is already in the url
$url = '/' . $this->graphVersion . '/oauth/access_token?client_id='
	. $prefs['socialnetworks_facebook_application_id']
	. '&redirect_uri=' . $this->getURL() . '&client_secret='
	. $prefs['socialnetworks_facebook_application_secr'];
///////START NEW CODE
// try ZendOAuth
$this->options['callbackUrl'] = $this->getURL();
$this->options['requestTokenUrl'] = 'https://graph.facebook.com/' . $this->graphVersion . '/oauth/access_token';
$consumer = new ZendOAuth\Consumer($this->options);
$httpClient = TikiLib::lib('tiki')->get_http_client();
$consumer->setHttpClient($httpClient);
$customServiceParameters = [
        'client_id' => $prefs['socialnetworks_facebook_application_id'],
        'client_secret' => $prefs['socialnetworks_facebook_application_secr'],
        'redirect_uri' => $this->getURL(),
        'code' => $_REQUEST['code']
];
/** @var ZendOAuth\Token\Request $token */
$token = $consumer->getRequestToken($customServiceParameters);
$resp = $token->getResponse();
$ret = $resp->getContent();
/////END NEW CODE
 $json_decoded_ret = json_decode($ret, true);
 if (isset($json_decoded_ret['access_token']) || substr($ret, 0, 13) == 'access_token=') {