Using the PHP SDK, I am trying to query for the statuses of a page. But the Graph Explorer returns an error (#100) Requires user session. Why is that? Querying for the feed of the page works without user authorization and statuses are just a subset of the feed, aren't they?
Is there any way I can extract from /feed or /posts what /statuses would return?
Related
I've recently been working with the graph API for Facebook and i want to create a script that lets me input a page_id and will then return the like count of the specified page.
I've already taken care of getting an access token and logging in, but i can't seen to find anything concerning the total like count of a page in the Reference.
This would be the API call:
https://graph.facebook.com/bladauhu?fields=fan_count&access_token=xxx
You can use any Token if the Page is not restricted by age or location. If it is restricted, you need a User or Page Token of a user who can see the Page.
More information:
http://www.devils-heaven.com/facebook-access-tokens/
https://developers.facebook.com/docs/facebook-login/access-tokens/
In facebook developers api page it says:
A Page in the Graph API.
The fields shown below are some of the common fields of Facebook Pages. Pages may also contain other (or additional) category-specific fields.
Does anyone know how to retrieve those additional category-specific fields???
I´ve been looking on Internet but not a clue :-(
The doc for the facebook 'page' table shows fields and lists what category of page they are available to:
https://developers.facebook.com/docs/reference/fql/page/
For example, the band pages have a 'band_members' field that no other page type has. You should also check out Facebook Graph API batch requests which you can use to query for something and use the result in a second request using JSONPath notation. Do a search on this page for JSONPath and you'll see it near the bottom under the 'Specifying dependencies between operations in the request' section:
https://developers.facebook.com/docs/reference/api/batch/
Hope that helps!
-Kyle
Say I have a page on Facebook and updating its status and posting on its wall.
What I want is getting that data in json or xml format and use it on my own web page.
All the api docs I've read so far requires an access token, which I shouldn't need.
Twitter has a rest api like http://twitter.com/statuses/user_timeline/twitter_username.json?count=10, which returns the data in json format. I need something like that.
Almost all Facebook graph API calls require an access token, including the page feed you seek. You can get the feed in json format like: https://graph.facebook.com/pageIdOrName/feed or https://graph.facebook.com/pageIdOrName/statuses but you will need to append an access_token querystring parameter. You can test this with the Facebook Graph API explorer, and you could even use that access_token if you don't want to create an application.
I'm trying to create a box on the side of a page that displays the 6 latest posts from a Twitter account and Facebook page. Twitter is working exactly how I want it to - Facebook is not.
The way I am doing it at the moment is to fetch the latest statuses using FQL as JSON usin cURL, caching them on the server, then displaying them in the same way as I am the tweets in the actual box.
My problem lies with the access token. I went away last night with it working, came back this morning and noticed that the modified date of my cached file hadn't changed. I checked the cached error file (where the fetched JSON gets dumped if it doesn't contain the data I need) and I had a session expired error. I then created a small function that uses cURL (3 cURL calls or one box, I know - urgh) to retrieve a new access token using the this URL:
https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=XXX&client_secret=XXXX
But I now get an error that a User Session is required, but all I want to do is to read the latest posts, that isn't user dependant at all. I really want to avoid using the Facebook SDK if possible.
Tl;dr - FQL seems to require users to log in even just to read statuses off of a set page's wall - what's the correct way of getting this data that doesn't require a user session (preferably without using the SDK).
If you're trying to get the status from a User account then you will require a valid user access token.
If you're getting statuses from a Fan Page then you just require a valid app access token - which can be obtained from:
https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
You can then use the returned access token to get the statuses from the target Fan Page.
SELECT id,status_id,message,time FROM status WHERE uid = XXXX LIMIT 6
You're querying by user id so that will require a valid user access token.
i'm trying to get a facebook page feeds using graph URL. but i want to get only the owner data ... i don't want anything not from the owner. i can do that using PHP. but i'm asking if i can do that using the same graph request.
Thanks
Just use /posts instead of /feed