Skip to content
pakainfo

Pakainfo

Web Development & Good Online education

  • Home
  • Blog
  • Categories
  • Tools
  • Full Form
  • Guest Post
  • Advertise
  • About
  • Contact Us

Get Facebook Access Token Using PHP SDK – Authentication

July 1, 2018 Pakainfo Programming, Mysql, Mysqli, php Leave a comment

Get Facebook Access Token Using PHP SDK – Authentication

Contents

  • Get Facebook Access Token Using PHP SDK – Authentication
    • Get Facebook Access Token
    • What is an access token?
    • User access token
    • System Requirements
    • getAccessToken.php
    • facebook_callback.php
    • Related posts

Get Facebook Access Token:

In this Post We Will Explain About is Get Facebook Access Token Using PHP SDK – Authentication With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to FacebookSession for the Facebook SDK for PHPExample

In this post we will show you Best way to implement How to handle access tokens with Facebook SDK, hear for Facebook API – Access Tokenswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Also Read This πŸ‘‰   Database Data Import to Excel File using laravel

First of all simple steps get Facebook Access Token we need to simple use a Libs Like as a PHP SDK 5.4 or more to communicate with devloper account to Facebook API. we can download here PHP SDK 5.0 from following click to free link Download Facebook PHP API SDK 5.4 or more.The Facebook simple free SDK for PHP provides a all the server native interface to the as well as Graph API and easy way to Facebook Login.

Example

What is an access token?

An access token is basically meaning of the really long ID as well as that is must required in order and api call to make calls to the facebook Graph API

Also Read This πŸ‘‰   Send Simple Mail Function using PHP

User access token

A user access token looks like this:

CAsdwiWr8tH8BadminOIgoMwJ9T0ZAmJ6KJJNc5s5stdlive24u1s37D6us6eCEoy9r2VgrCLffCTvEGe9cZBZPAwBhygi2ZpTubZC2eCzfreStWG989898dXu4uJl2CCLiFXEtP4GKDv0Gk4s35iXty77KZBx5NYBCcEUsdownlJQcXLsb1X2ZsdfgsysDZN

System Requirements:

1. PHP 5.4 or greater
2. The simple Curl extension
3. The simple mbstring extension

getAccessToken.php

//include libs
require_once __DIR__ . '/FacebookSDK/src/Facebook/autoload.php';
 
//pass arguments
$facebook_args = array(
      'consumer_key' => '19586578458256',
    'consumer_secret' => 'bb3f2d58c73526b9aa0252a8813282f0',
    'default_graph_version' => 'v2.2'
);
 
$fbObj = new Facebook\Facebook($facebook_args);
 
$fb_args_param = array('req_perms' => 'publish_actions');
$live_helper = $fbObj->getRedirectLoginHelper();
$fb_login_url = $live_helper->getLoginUrl('facebook_callback.php', $fb_args_param);
 
header('Location: '. $fb_login_url);
exit;

Now we need to allow some checkbox checked permission by click on Okay

facebook_callback.php

 
//include libs
require_once __DIR__ . '/FacebookSDK/src/Facebook/autoload.php';
 
//pass arguments 
$facebook_args = array(
    'consumer_key' => '19586578458256',
    'consumer_secret' => 'bb3f2d58c73526b9aa0252a8813282f0',
    'default_graph_version' => 'v2.2'
);
 
$fbObj = new Facebook\Facebook($facebook_args);
 
$live_helper = $fbObj->getRedirectLoginHelper();
try {
// here facebook getAccessToken
  $get_accessToken = $live_helper->getAccessToken();
 var_dump($get_accessToken);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
	//some message return
  echo 'we are fb Graph returned some an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
	//some message return
  echo 'we are fb Facebook SDK returned some an error: ' . $e->getMessage();
  exit;
}

Now to extend the validity of this and get the access token use following source code after just mini to getting access token.

Also Read This πŸ‘‰   Access Tokens - Facebook Login - Facebook Open Graph API

$colient_Auth2 = $fbObj->getOAuth2Client();
var_dump($colient_Auth2);
$get_accessToken = $colient_Auth2->getLongLivedAccessToken($get_accessToken);
var_dump($get_accessToken);

Now the simple steps to easy way access toke will be valid for next (3 months) 60 days.

I hope you have Got What is How To: Get A Facebook Application Access Token And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Related posts:

  1. PHP Secure Token Generator Authentication tutorial
  2. Multiple image slider in html source code
  3. How To Create Image Hover Overlay Effects?
  4. How To Create Social Media icons footer using bootstrap?
facebook php get access tokenfacebook php sdkget access token facebook php curlget access token facebook without loginget user access token facebook phphow to get access token facebook graph apihow to get access token facebook graph api javascripthow to use access token facebook php

Post navigation

Previous Post:jQuery Validation Email Mobile password Regular Expression
Next Post:WordPress AJAX URL GET POST Call PHP Function

Advertise With Us

Increase visibility and sales with advertising. Let us promote you online.
Click Here

Write For Us

We’re accepting well-written informative guest posts and this is a great opportunity to collaborate.
Submit a guest post to [email protected]
Contact Us

Freelance web developer

Do you want to build a modern, lightweight, responsive website quickly?
Need a Website Or Web Application Contact : [email protected]
Note: Paid Service
Contact Me

Categories

3movierulz (64) Ajax (464) AngularJS (377) ASP.NET (61) Bio (109) Bollywood (108) Codeigniter (175) CSS (98) Earn Money (69) Education (61) Entertainment (130) fullform (86) Google Adsense (63) Highcharts (77) History (40) Hollywood (109) JavaScript (1357) Jobs (42) jQuery (1423) Laravel (1088) LifeStyle (53) movierulz4 (63) Mysql (1029) Mysqli (890) php (2121) Programming (2332) Python (97) Software (166) Software (88) Stories (98) tamilrockers (104) Tamilrockers kannada (64) Tamilrockers telugu (61) Tech (142) Technology (2392) Tips and Tricks (119) Tools (203) Top10 (478) Trading (90) Trending (71) VueJs (250) Web Technology (105) webtools (191) wordpress (166) World (322)

A To Z Full Forms

Access a complete full forms list with the meaning, definition, and example of the acronym or abbreviation.
Click Here
  • Home
  • About Us
  • Terms And Conditions
  • Write For Us
  • Advertise
  • Contact Us
  • Youtube Tag Extractor
  • Info Grepper
  • Guest Posting Sites
  • Increase Domain Authority
  • Social Media Marketing
  • Freelance web developer
  • Tools
Pakainfo 9-OLD, Ganesh Sco, Kothariya Ring Road, Chokadi, Rajkot - 360002 India
E-mail : [email protected]
Pakainfo

Β© 2023 Pakainfo. All rights reserved.

Top
Subscribe On YouTube : Download Source Code
We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype Guest Posting Sites