Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Answers: 1. I think you are on the right track. You could also ensure that a [native user] logged in can access the sign up page and push the FB account join to user profile page or something like that.</p> <ol start="3"> <li>You could easily get the user id since its a public info provided by facebook for all registered accounts. But that user will need to allow your app inorder to be able to get their info from facebook profile. But the good news is that almost all the work is done by facebook for you and you just have to point the user to the right url. There is also the social plugin that you could to register users on your site/app with the <a href="https://developers.facebook.com/docs/plugins/registration/" rel="noreferrer">Facebook register social plugin</a></li> </ol> <p>As noted in in the facebook api documentation, <code>$uid</code> will contain the facebook user id of the current user [browsing your site] or null after a call to <code>$uid = $facebook->getUser();</code></p> <p>So first of, you could check that the $uid is valid [not null or zero]. Then if is passes that test, you could attempt to retrieve the public profile info by issuing a <code>$user = $facebook->api('/me')</code>. That should provide your with the user profile if the is logged in to facebook already. If not then the user perhaps has a facebook account but not logged in.</p> <blockquote> <p>Note that the api('/me') could throw an exception if the right token was not passed, so you should wrap it in a try-catch block and handle the exception according to your app.[Perhaps assume that the user is not logged in. If you are sure that your app_id and secret id are valid ]</p> </blockquote> <p>If $user is null then you can get the url to redirect the user to [for facebook login ] by calling <code>$loginUrl = $facebook->getLoginUrl()</code> and redirect the user or provide a clickable link to URL. </p> <p>All these are documented in the <a href="https://developers.facebook.com/docs/reference/php/" rel="noreferrer">facebook api documentation</a></p> <p>Sample Code:</p> <pre><code>&lt;?php require_once("facebook.php"); $config = array(); $config['appId'] = 'app id'; $config['secret'] = 'secret app id'; $facebook = new Facebook($config); $uid = $facebook-&gt;getUser(); if( ! $uid){ // we have an id try{ $user = $facebook-&gt;api('/me'); //get the current user's FB public profile if($user){ // we have a valid user who is logged in to his facebook account $logoutURL = $facebook-&gt;getLogoutUrl(); // user } }catch(FacebookApiException $e){ $user = null; $loginURL = $facebook-&gt;getLoginUrl(); } } </code></pre> <p>Again all these are documented in the facebook PHP client so its your best choice to start. Facebook changes its api without much notification so you should visit their developer page in case your code start to behave strangely. </p> <p>Hope it helps!</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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