I've only JavaScript code, but once you have an access token, you may get the pages which can be adminstered by the given user. This will contain a page access token for each of them: Show
The data given back is like:
As the Facebook PHP SDK v4.0 gets closer and closer to the next big release of version 4.1 (probably in August or September of 2014), the internal structure keeps getting more and more decoupled. And that's a very, very good thing! But good things have also recently happened in the 4.0 branch. In version 4.0.9 access token handling has been completely decoupled, and it is now possible to work directly with access tokens with the SDK.
What is an access token?An access token is basically a really long ID that is required in order to make calls to the Graph API. The token identifies the following:
It also contains information about the time in seconds until the access token expires and sometimes contains an identifier called a Short-lived vs long-lived access tokensBy default, when you request a user access token, Facebook will return a short-lived access token which will expire in 2 hours. Or as the official documentation states, "about an hour or two". I'm not sure the reason for the fuzzy time explanation. This short amount of time could be problematic if you plan on storing the access token in your database and using it to make requests to Graph later. So you'll need to exchange the short-lived access token for a long-lived access token which will be valid for 2 months before it expires. In order to extend your short-lived access token with a long-lived access token, you'll need to use the new Types of access tokensThere are a number of different access tokens that can be used to interact with Graph. For convenience, Facebook provides an access token tool that lists access tokens for the various apps that you administrate. There's also an access token debugger that will decode an access token and return the underlying identifying data. But not all access tokens are the same. Depending on what you want to do, you'll need to send a different token with your request to Graph. User access tokenPerhaps the most well-know and widely used access token is the user access token. This is the access token you want to use when making calls to Graph on behalf of a specific user. A user access token looks like this:
And a user access token will allow you to:
Obtaining a user access tokenUser access tokens can be obtained via the Facebook PHP SDK v4 "helpers". The most common helper is the
Page access tokenA page access token looks just like a user access token. It also identifies the target page ID. This is the token you want to use to perform actions on behalf of a specific page such as:
Obtaining a page access tokenPage access tokens can be obtained from a user who has administrator privileges to the target page and has
also authorized your app with the
The page access tokens that are returned from the You'll also notice a App access tokenAn app access token looks like this:
The token is made up of the app ID and the app secret or a valid hash of the app secret. An app access token will allow you to manage the app information including:
Obtaining an app access tokenApp access tokens don't require any calls to Facebook to obtain. You can make an access token by concatenating the app ID with the app secret and using a pipe delimiter.
App access tokens don't expire. And since they contain the app secret, you never want to use them on the client side. The new AccessToken entityYou saw it first in the Facebook Query Builder and now the Extending a short-lived access tokenOnce you obtain a valid
Getting detailed information about an access tokenThe Graph API
has a useful
Of course if you just want to debug a token while you're developing your app, you can always use the convenient debugger provided by Facebook. Best practices for maintaining long loved access tokens over timeIf your app is sending requests with a long-lived access token to the Graph API on behalf of your users frequently, your app is at risk of being flagged for spam. In order to avoid this, you can use a code to get new long-lived tokens. The basic flow goes something like this:
<<EOF;As you can see access tokens aren't as confusing as they seem at first. Since the SDK makes it so easy to handle access tokens, the hardest part on your end is figuring out which access token you'll need to solve your particular problem. If you want to dive deeper, check out the official access token documentation on Facebook. If you found this guide helpful, say, "Hi" on twitter! I'd love to hear from you. :) How do I find my page token?To get a Page access token, send a GET request to the /PAGE-ID endpoint using your User access token. Replace PAGE-ID and USER-ACCESS-TOKEN with your information. If you used a short-lived User access token, the Page access token is valid for 1 hour.
What is access token in Facebook API?An access token is an opaque string that identifies a user, app, or Page and can be used by the app to make graph API calls. When someone connects with an app using Facebook Login and approves the request for permissions, the app obtains an access token that provides temporary, secure access to Facebook APIs.
How do I get data from Facebook Graph API?Open the Graph Explorer in a new browser window. This allows you to execute the examples as you read this tutorial. The explorer loads with a default query with the GET method, the lastest version of the Graph API, the /me node and the id and name fields in the Query String Field, and your Facebook App.
How can I get token without login?No, there is no way. You can only extend User or Page Tokens. Extended User Tokens are valid for 60 days, Extended Page Tokens are valid forever.. The token that I use now is a user_token. ... . 'You can also try using an App Token, it is just a combination of App ID and App Secret.. |