PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 11, 2022

[FIXED] facebook connect api static url

 February 11, 2022     facebook, facebook-php-sdk, php     No comments   

Issue

Is there a way to use the facebook connect api in a static way?

When we use the facebook php sdk the link or button to login to facebook is something like https://www.facebook.com/dialog/oauth..................

what I want is to eliminate the include of the php sdk on every page, because it will cause some extra processing and server load in peak times.

I want to make a session check to know if the user is logged in, by checking for exemple if his facebook user id and name are stored in the session, then if not, display a static login button. then after login with facebook he gets to facebook-login.php which will include the facebook php sdk and process his data and store them in the session, so that he remains logged without including the php sdk in each page.

the url structure that I get with $facebook->getLoginUrl() is:

https://www.facebook.com/dialog/oauth?client_id={MY_APP_KEY}&scope={PERMISSIONS}&redirect_uri={MY_SITE/facebook-login.php}&state={A_32_CHAR_CODE_LIKE_MD5_MAYBE}

The final question is: WHAT WOULD BE THE URL IN THE LOGIN BUTTON?


Solution

just load the sdk and do something like:

echo '<a href="' . $facebook->getLoginUrl( array('next'=>'http://mysite.com', 'req_perms' => 'email,read_stream,publish_stream')) . '">Connect to Facebook</a>';

that url will always be valid for a logged out user



Answered By - Trey
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing