Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thank you for contacting me on my blog. First of all, Facebook is discontinued the localhost support. Her is the link <a href="https://developers.facebook.com/bugs/128794873890320" rel="nofollow">https://developers.facebook.com/bugs/128794873890320</a>. </p> <p>I have not developed any app using codeigniter, I use CakePHP but the auth follow should be same.<br> 1. Create a fb_login function in user controller.<br> 2. This function will follow this logic. a. Use <code>$facebook->getUser()</code> to get user id. b. Then use <code>$facebook->api('/me')</code> to be sure.<br> 3.If you get FacebookApiException then send user to login with Facebook. If you use official SDK then the current url will be added to redirect url.<br> 4.the Facebook will redirect your user after sign in. so you will get data using <code>$facebook->getUser()</code>. Save this data in session for further use in you app. then redirect user to you control page or any other page. CakePHP has <code>setFlash()</code> function wich show what ever msg set in the control panel in view. I think Codeignator should have some thing like this. If not you can simply set a msg in session and redirect user. Then unset the msg after showing the msg. </p> <p>Here is full code <code></p> <pre><code>$uid = $facebook-&gt;getUser(); try { $user_profile = $facebook-&gt;api('/me'); } catch (FacebookApiException $e) { //echo $e-&gt;getMessage(); $uid = null; } $loginUrl = $facebook-&gt;getLoginUrl( array( 'scope' =&gt; 'publish_stream,offline_access,email' ),'' ); if (!$uid) { echo "&lt;script type='text/javascript'&gt;top.location.href = '$loginUrl';&lt;/script&gt;"; exit; } //search using uid on your user table to check if the use is returnign user or new user. if($new_user ==1) { $this-&gt;Session-&gt;setFlash('please sign up'); //redirect to sign up } else { $this-&gt;Session-&gt;setFlash('you are good lad'); //reditect to control panel } </code></pre> <p></code></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.
    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