Issue
Through Facebook's PHP SDK getting started guide it takes you through the process of initializing your app, creating a Login URL and then handling the call back data and doing a simple query.
In the documentation it says you can skip the initializing process providing an access token from 'some other means'.
$session = new FacebookSession('access token here');
Due to the lack of documentation I'm struggling on how I would define a scope before creating the login URL and then use the call back data to extract the access token.
Solution
This tutorial will help you get started with using the Facebook PHP SDK to log a user in.
Basically, you need to setup your application first and use the FacebookRedirectLoginHelper
to create the login URL:
FacebookSession::setDefaultApplication( 'xxx','yyy' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper( 'http://yourwebsite.com/app/' );
// show login url, scope is array of permissions
echo '<a href="' . $helper->getLoginUrl( [ 'email', 'user_friends' ] ) . '">Login</a>';
Answered By - Niraj Shah
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.