Facebook Graph API: What is the access token used? - php

I am attempting to access a status/photo summary of a facebook Post. I attempted to use graph explorer tool to get the summary, which is successful.
Now what happens is I have an app, which has the same permissions I've given to the graph explorer tool (user_status, user_photos). I then build a URL like this:
https://graph.facebook.com/{post_id}?access_token={my_app_access_token}
The access token I'm using is obtained from this link, but all I get is an error. Am I using a wrong access token? If I am, how should I be getting the correct access token?

Related

Get Facebook Marketing API Access Token Using Ads PHP SDK

I was wondering how does one get access to the FB Marketing API Access Token using the Ads SDK. Currently am I manually doing this:
https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&redirect_uri=
<http://yourwebsite.com/>&scope=ads_management,manage_pages,publish_actions
Which returns a code like this:
?code=<your auth code>
Then I input into the next URL provided by FB:
https://graph.facebook.com/<API_VERSION>/oauth/access_token?client_id=<APP_ID>&
redirect_uri=<http://www.yoursite.com>&client_secret=<APP_SECRET>&code=<CODE>
This gives me the access token, but am assuming there is a better way to get the access token using the Ads PHP SDK provided? I hope. If anyone can help. Please share, thanks!
You can extend an access token to be a 'long-lived' server-side token. This extension will give it a lengthy expiration. More info here: https://developers.facebook.com/docs/facebook-login/access-tokens#long-via-code
You can also authenticate via the PHP SDK as you mentioned. Get started here: https://github.com/facebook/facebook-php-ads-sdk/blob/master/DEVELOPER_GUIDE.md#authentication-

Facebook Access Token Invalid for search endpoint

i am making this request through graph api and i am getting this error:
(#200) Must have a valid access_token to access this endpoint
A couple of days ago i was making the same requests without any problem and now i keep getting this error messages, i don't know why. the query i am requesting is the following:
/search?q=SOMETHING&type=event&fields=id,name,description,cover,start_time,end_time,location,owner,venue&limit=5000&access_token=ACCESS_TOKEN.
This query works on graph api explorer (including the access token). My question is, the error is mine or from facebook?
Thanks.
Put the Access Token in the Debugger and check if it´s valid: https://developers.facebook.com/tools/debug/
If yes, file a bug: https://developers.facebook.com/bugs/

Is there a way on how to get an access token for User Data Permission in PHP?

I am using PHP to work on Facebook, and I want to get an access_token to get User Data Permission for items like
email
user_actions.music
user_activities
user_events
user_location
etc.
I know this can be done by using Graph API Explorer in Facebook developers. Can you show me how to do this in PHP? Thanks!
After include'ing the Facebook SDK for PHP, simply call $facebook->getLoginUrl with appropriate parameters.

Restricted Facebook Page Details over Graph API using PHP SDK

I'm trying to use Facebook's PHP SDK to get the number of likes for a fan page. This works fine for most pages, but some pages are returning false because they have age restrictions. Using the PHP SDK, how do I get the number of likes for an age restricted fan page over the graph API?
I'm currently not using an access token to read the pages. Would an app access token work? And if so how do I use an app access token with the PHP SDK.
Restricted pages can be read using the graph api but it requires a user's access token. I had tried it with an app access token which does not work.
The relevant documentation can be found here: https://developers.facebook.com/docs/reference/api/page/
You should to use Page access token. To get list of your pages with access tokens, use me/accounts method of the Graph API.

How to post to facebook wall once I've got the access token

I'm making a facebook app and have got as far as getting the user to allow my apps permissions, which then generates a code. Then using this code to get an access token. So I now have a variable in my PHP script containing the access token. Now how do I use this to post to the users wall?
The easiest way to post a message on the wall is through the graph api. You require the publish_stream permission to post status messages. You can simply do a POST with the desired message and the access token.
See the official facebook documentation for more details: http://developers.facebook.com/docs/reference/api/status/
Facebook changes their API so often, it's best to read their docs, if those are up to date...
Check in IRC #facebook as well.
But basically, you pass that token in to the API call somewhere, somehow and it's in their docs somewhere.
Unless FB has decided you don't need it or ignores it or doesn't want to allow that this week.

Categories