Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to to open redirected page after facebook authentication
    primarykey
    data
    text
    <p>i am using facebook connect under codeigniter.after authentication i want to redirect on success method of my controller here is my controller:</p> <pre><code>class Welcome extends CI_Controller { function __construct() { parent::__construct(); $this-&gt;load-&gt;model('Facebook_model'); } function index() { $fb_data = $this-&gt;session-&gt;userdata('fb_data'); $data = array( 'fb_data' =&gt; $fb_data, ); $this-&gt;load-&gt;view('welcome', $data); } function topsecret() { $fb_data = $this-&gt;session-&gt;userdata('fb_data'); if((!$fb_data['uid']) or (!$fb_data['me'])) { redirect('welcome'); } else { $data = array( 'fb_data' =&gt; $fb_data, ); $this-&gt;load-&gt;view('topsecret', $data); } } function success() { $this-&gt;load-&gt;view('welcome_message'); } } </code></pre> <p>my model for facebook api access:</p> <pre><code>class Facebook_model extends CI_Model { public function __construct() { parent::__construct(); $config = array( 'appId' =&gt; '261066574000678', 'secret' =&gt; ' 79e11f65449988965362f58e9a4aabd7', 'fileUpload' =&gt; true, // Indicates if the CURL based @ syntax for file uploads is enabled. ); $this-&gt;load-&gt;library('Facebook', $config); $user = $this-&gt;facebook-&gt;getUser(); // We may or may not have this data based on whether the user is logged in. // // If we have a $user id here, it means we know the user is logged into // Facebook, but we don't know if the access token is valid. An access // token is invalid if the user logged out of Facebook. $profile = null; if($user) { try { // Proceed knowing you have a logged in user who's authenticated. $profile = $this-&gt;facebook-&gt;api('/me?fields=id,name,link,email'); } catch (FacebookApiException $e) { error_log($e); $user = null; } } $fb_data = array( 'me' =&gt; $profile, 'uid' =&gt; $user, 'loginUrl' =&gt; $this-&gt;facebook-&gt;getLoginUrl( array( 'scope' =&gt; 'email,user_birthday,publish_stream', // app permissions 'redirect_uri' =&gt; 'https://sanjay.localhost.com/index.php/welcome/success' // URL where you want to redirect your users after a successful login ) ), 'logoutUrl' =&gt; $this-&gt;facebook-&gt;getLogoutUrl(), ); $this-&gt;session-&gt;set_userdata('fb_data', $fb_data); } } </code></pre> <p>since i am testing this on localhost host,i also edited my host file and changed my localhost hostname to sanjay.localhost.com.redirect happens but not happens..i think may be because of querystring.when redirects happens redirect uri is<br> =">https://sanjay.localhost.com/index.php/welcome/success?state=ff5712299510defa&amp;code=AQCaD-FAd1shuW#<em>=</em><br> i am not understanding how to handle state and code inside of query string. please help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload