How to generate FB page access token
Posted By : Deepak Rawat | 28-Dec-2015
Ever wondered how to generate FB page access token, here is how. Used in graph API calls to manage Facebook pages. Admin of page must grant extended permission called manage_pages, for generate page access token.
You can retrieve page access token, once this permission has been granted using following graph API request :
HTTP
GET /me/accounts HTTP/1.1
Host: graph.facebook.com
PHP SDK
$request = new FacebookRequest(
$session,
'GET',
'/me/accounts'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
JavaScript SDK
FB.api(
"/me/accounts",
function (response) {
if (response && !response.error) {
/* handle the result */
}
}
);
Android SDK
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/accounts",
null,
HttpMethod.GET,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
}
}
).executeAsync();
iOS SDK
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
initWithGraphPath:@"/me/accounts"
parameters:params
HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
id result,
NSError *error) {
// Handle the result
}];
You can use this type of token to make API calls on behalf of page. For example, you can post status update to page or read page insights data.
Page access token are unique are unique to each admin, page and application.
THANKS
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Deepak Rawat
Deepak is a Web and Mobile application Sr. Lead Frontend developer and good working experience with JQuery , AngularJS , Javascript and PhoneGap. His hobbies are listening to music and photography.