We use Facebook's comments plugin for users to post comment on our pages. I wanted to fetch the Facebook comments using Facebook's graph API. The API call is pretty straightforward :
Example : GET /v2.6/<comments_fbid>/comments
This works from the Facebook graph explorer.
However, I am getting this comments_fbid using this URL :
https://api.facebook.com/method/links.getStats?urls=[my-site-url]&format=json
Sample response:
[
{
url: "<my-url>",
normalized_url: "<my-url>",
share_count: 33412170,
like_count: 28816093,
comment_count: 8485499,
total_count: 70713762,
click_count: 0,
comments_fbid: "10150187081535131",
commentsbox_count: 5197
}
]
This is an undocumented (and possibly deprecated?) API. How can I get the comments_fbid from the call to the graph API? Am I missing something here?
This is the same id on the hyperlink for the moderation tool on the page if you're signed in :
//developers.facebook.com/tools/comments/url/<comments_fbid>/pending/descending/
It's hard to test without your actual site URL, but I think you want something like this:
GET /v2.6/?id=http://www.Facebook.com&fields=og_object
Documentation is here: https://developers.facebook.com/docs/graph-api/reference/v2.6/url/
Related
I am using the SeatGeek API to pull some data for sporting events. The results of the call I get show 145,000+ results returned in the metadata:
meta : {u'per_page': 10, u'total': 145419, u'geolocation': None, u'page': >1, u'took': 7}
in_hand : {}
When I look at the "Pagination" section of the API documentation, it gives examples of how to format the syntax in order to see more results per page, or to return a different page than the first one:
$curl 'https://api.seatgeek.com/2/venues?per_page=25&page=3'
But I can't get it to call successfully with the authorization I've been given from SeatGeek:
$curl https://api.seatgeek.com/2/events?client_id=MYCLIENTID&client_secret=MYCLIENTSECRET
I have tried using curl and python requests. I have tried putting the pagination syntax first and the "clientid/secret" second. I've tried putting the "clientid/secret" first. I've emailed the mods for the API to no avail.
This is the first API call I've ever made, so I'm sure there's some tiny formatting error I'm making.
The calls return successfully when I'm not using pagination. I just can't view more than one page of the results, and I'd like to view everything.
Thank you.
For sake of completeness and closure, I'm posting this as an answer:
OP used ? instead of & between the URL parameters. The correct URL is https://api.seatgeek.com/2/events?client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&per_page=25&page=3.
When I used Facebook's Open Graph API, I noticed that the JSONP responses generated by Facebook seemed to have an extraneous "/**/" at the beginning of each response like this:
URL:
https://graph.facebook.com/SOME_ID?method=get&pretty=0&sdk=joey&callback=FB.__globalCallbacks.f1c77f051c
Response:
/**/ FB.__globalCallbacks.f887adeec(...);
Why is this?
We added this to protect against an attack where a third party site bypasses the content-type of the response by doing: <object type="application/x-shockwave-flash" data="http://graph.facebook.com?callback=[specifically crafted flash bytes]"></object>
Google does something similar, except they use //... + \n (e.g. http://www.google.com/calendar/feeds/developer-calendar#google.com/public/full?alt=json&callback=foo)
Certainly to prevent XSSI... so you can't execute it...
http://maxime.sh/2013/02/javascript-quest-ce-que-le-xssi-et-comment-leviter/&usg=ALkJrhhjfdwBrK7kxNipOowAYacIcJm89g">Here is a french blog post about that (with google translate)
To prevent XSSI
look into the graph of facebook for more help
https://developers.facebook.com/docs/opengraph/overview/
Seems like Facebook is using a scrubber on their JSON, and it's just leaving the remaining comment holder at the beginning. Most likely leave comments there for debugging purposes, but in production the actual comments are scrubbed.
I came across to what I think is a weird behavior of the graph api..
From the facebook reference page https://developers.facebook.com/docs/reference/api/
, I tried the newsfeed method https://graph.facebook.com/me/home?access_token=...
and get the following json response:
{
"data": [
]
}
but than clicking on refresh button I get a feed:
and this is happening randomly at every refresh.. some of them with data in response some of them empty..
Looks like fb servers are out of sync.. and it depends which one you hit..
is this happened to someone else?
thanks.
I looked here: https://developers.facebook.com/live_status and it appears there is some issues but not anything related to what you're saying. I remember there was another question over the weekend from someone saying they were getting back different results from the same query, but I cannot remember what it is. #John, it sounds like the issue is reproducible, so you should file a bug report: https://developers.facebook.com/bugs
I have a question.
I think that Facebook C# GRAPH API only supports method that get most recently posts or messages.
example)
JSONObject me = fbAPI.Get("/me/feed?access_token=" + this.app_access_token);
Is there any additional parameter to get the previous posts or messages?
If it's not possible, Is Other API ( PHP, Javascript ... ) supporting this?
-jack-
I'm not entirely familiar with the C# SDK, but if it follows the convention of other Graph API compatible SDKs you should be able to do this:
JSONObject me = fbAPI.Get("/me/feed?limit=25&since=1311007970&access_token=" + this.app_access_token)
The limit parameter will restrict the number of posts that are retrieved at once and the since parameter is a Unix timestamp that will allow you to query for posts further back in time. Check out the Paging section on this page for more information:
https://developers.facebook.com/docs/reference/api/#reading
I'm building an app which allows users to post articles to their facebook wall. When an article is posted, I retrieve the post id and store that in the database along with the rest of the article details. Now I want to be able to show the comments made on that post when someone views the article in my site; I would also like to allow users to add comments to the post from my site.
I know that the user is always logged into Facebook when they are viewing the article, as the system checks for that earlier on.
I've been using the PHP SDK, and thought all I had to do was something like:
$post_comments = $facebook->api('/' . $post_id . '/comments');
However, when I do this, I get the following error:
Fatal error: Uncaught GraphMethodException: Unsupported get request. thrown in /APP_PATH/facebook/src/facebook.php on line 560
I really don't have much of a clue what I'm doing here, to be honest, as I'm very new to the Facebook Graph API, and I can't seem to find a lot of documentation on it.
Can anyone tell me what I should be doing here, or point me to some documentation I could read about it?
Thanks!
It should work.
Here is the code I am using which is working for me.
$comments = $facebook->api($postid . '/comments');
Make sure your postid is a valid one.
Alternatively, you can directly type that url in browser to get details like this
https://graph.facebook.com/<postedid>/comments
Please refer this link for further reference
http://developers.facebook.com/docs/reference/api/Comment/
I don't know what your PHP library is doing, but you can actually access comments by reading graph.facebook.com/<post_id>/comments. Indeed, try with this one from the doc.
Are your sure of your post id? Try to call the buggy function with 19292868552_118464504835613 as post id. It has to work.