Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP SDK + Code Igniter
    primarykey
    data
    text
    <p>First, I downloaded the Facebook PHP SDK and applied the first answer in here: <a href="https://stackoverflow.com/questions/9454238/using-facebook-php-sdk-3-x-to-register-login-user-with-codeigniter-2-1-0">Using Facebook PHP-SDK 3.x to register/login user with Codeigniter 2.1.0</a></p> <p>In my controller:</p> <ol> <li><p>I try to get the user: $this->facebook->getUser(); .. If it's 0, I call another function $this->facebook_login(); - else I save some data in the database like name for example.</p></li> <li><p>In facebook_login(), a Login Url is generated: $this->facebook->getLoginUrl() - and is passed to the view, which displays it.</p></li> <li><p>So far I click on the login url and it redirects to Facebook, asks for approval and authentication and so on - then redirects me back to the page in "1". </p></li> <li><p>The problem is, getUser is returning zero. I printed the $<em>SESSION variable and found out that only fb</em>{appId}_state is being set.</p></li> </ol> <p>I tried creating another php file (login.php) that is not in the CI folder with the following code:</p> <pre><code>&lt;?php define('BASEPATH', ''); require_once('application/libraries/facebook.php'); $fb = new Facebook(array('appId'=&gt;'...', 'secret'=&gt;'...')); $user = $fb-&gt;getUser(); if($user == 0){ $login = $fb-&gt;getLoginUrl(); echo '&lt;a href="'.$login.'"&gt;Login&lt;/a&gt;'; } else { print_r($fb-&gt;api('/me')); } ?&gt; </code></pre> <p>If I visit login.php then visit the page in "1" above - getUser returns the user id and $_SESSION contains the user details.Therefore, I guess the problem is with CodeIgniter but I am not sure how to solve it.</p> <p>I searched and tried several solutions but that's the best I could do. If possible, I don't want to use the JS SDK.</p> <p>Thank you</p>
    singulars
    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