I have created a web server in php, it receives Facebook user access through my webpage and checks that it is valid I want to get basic information about that user, but I'm not getting any way to do this. Can anyone help me?
& lt; Php require_once ('php-sdk / facebook php'); $ Config = array ('appId' = & gt; 'YOUR_APP_ID', 'secret' = & gt; YOUR_APP_SECRET ',' allowSignedRequest '= & gt; false // should be set to false but false for non-canvas app ); $ Facebook = new Facebook ($ config); $ User_id = $ facebook-> GetUser (); ? & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php if ($ user_id) {// We have a User ID, so possibly a logged user // If not, we will get an exception, which we handle below I {$ User_profile = $ facebook- & gt; Try the API ('/ m', 'GET'); Echo "name:" $ user_profile ['name']; } Hold (FacebookApiException $ e) {// If the user is logged out, you may have a // user ID, although the login token is invalid. In this case, we will get an exception, therefore, we just // Ask again to enter. $ Login_url = $ facebook- & gt; GetLoginUrl (); Echo 'please & lt; A href = '' $ login_url. ' "& Gt; Login. & Lt; / a & gt; 'error_log ($ E & gt; GetType ()); error_log ($ E & gt; getMessage ());}} Else {// Any user, Please print a link for user login $ url = $ facebook- & gt; getLoginUrl (); echo 'a'l' a href = '' $ login_url. ' "& Gt; Login. & Lt; / A & gt; '; }? & Gt; & Lt; / Body & gt; & Lt; / Html & gt;
You are logged in after using this command to retrieve the user data array:
$ user_profile = $ facebook- & Gt; API ('/' 'received');
Or you can use it to get the user by ID (another user)
$ user_profile = $ facebook- & gt; API ('userID', 'Received');
You can find what you need here:
https://developers.facebook.com/docs/reference/php/ < / Code>
Comments
Post a Comment