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

Friday, February 11, 2022

[FIXED] Acquiring Long Lasting Facebook Token

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

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
  • 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