Facebook Real-Time updates: comment on post vs comment on album - facebook

Status entry comment:
{"object":"page","entry":[{"id":"106182246249179","time":1386582683,"changes":[{"field":"feed","value":{"item":"comment","verb":"add","comment_id":"185457974988272_294727","parent_id":185457974988272,"sender_id":106182246249179,"created_time":1386582683}}]}]}
Album comment:
{"object":"page","entry":[{"id":"106182246249179","time":1386581446,"changes":[{"field":"feed","value":{"item":"comment","verb":"add","comment_id":"185444231656313_190183","parent_id":185444231656313,"sender_id":100006218707108,"created_time":1386581446}}]}]}
They seem impossible to distinguish. However, the first one's real post id is pageid_parentid = 106182246249179_185457974988272. If you try to do the same thing with the album comment to get the feed from the stream FQL table, you won't get anything (or an exception with graph api).
Has anyone found a way to distinguish somehow between the two?

Yes.
First you need the object_id
object_id=pageid_parentid
Make this api call with the object id:
GET https://graph.facebook.com/v2.9/{object-id}?fields=type,status_type&access_token=token
The response should look something like this if the parent is a post:
{
"type": "status",
"id": "106182246249179_185457974988272"
}
If it's an album, it will look like this:
{
"type": "photo",
"id": "106182246249179_185457974988272"
}

Related

How to query facebook with FQL to get usernames who liked and commented on a post or a photo

Ok what i want to do is simple but i am not sure it can be done or not
Here my post and image that i want to query
Original share image :
https://www.facebook.com/MonsterMMORPG/photos/a.551985868170404.1073741825.198765706825757/694573437244979/?type=1
The reshare of the image
https://www.facebook.com/MonsterMMORPG/posts/699889243380065
Now i want to get people who liked image and post and also commented on them
I am trying to get userids of who liked via FQL like below but it returns nothing
SELECT user_id FROM like WHERE post_id=699889243380065
I am doing this at graph api explorer panel here screenshot
first image works second fails
You can use Facebook-graph-api to get your list of likes, as follows:
https://graph.facebook.com/v2.0/699889243380065/likes
(with valid tokens of course)
You'll receive the following list:
{
"data": [
{
"id": "xxx",
"name": "xxx"
},
{
"id": "xxx",
"name": "xxx"
},
etc
To get list of comments via graph-api:
https://graph.facebook.com/v2.0/699889243380065/comments

Facebook Post likes

I've a question in regards to the FB Graph API. Assuming I would like to search for the likes related to a Facebook post,I would have to do this:
541729512538864_792100727501740/likes/
But what If I would like to find whether a user(me) has liked that specific post(not page)?I've tried doing it this way.
541729512538864_792100727501740/likes/<my user id>
But it does not return any results.So what would would the actual Graph path be?I would gladly appreciate any help,thank you :D!
With the Graph API this is not possible imho. You'll need to use FQL instead:
select post_id, like_info.user_likes from stream where post_id="541729512538864_792100727501740"
will return
{
"data": [
{
"post_id": "541729512538864_792100727501740",
"like_info": {
"user_likes": false
}
}
]
}
in my case. This is always bound to the User of the Access Token you're using to running this query with. See https://developers.facebook.com/docs/reference/fql/stream/ for a reference.

How to get the right Data to an external URL and the right ID through the API?

is there a possibility to get more informations to a specific url e.g. preview image, title and short description through the open graph? If you do something like this, you only get the "shares" //graph.facebook.com/http://www.google.de
It's a bit confusing, when I get the ID via FQL through the object_url Table I get a different ID to the ID I get from the Debugger.
Getting the ID:
//graph.facebook.com/fql?q=SELECT%20url,id,type,site%20FROM%20object_url%20WHERE%20url%20=%20%22http://google.de%22
Result: "id": 6319338796</pre>
Trying to get the Data with that ID failed (acces token needed)
//graph.facebook.com/6319338796/
"message": "An access token is required to request this resource."
Get the ID with the Debugger:
//developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fgoogle.de
Getting the Result from ID 438699604740 (no problem):
//graph.facebook.com/438699604740
{
"url": "http://www.google.de/",
"type": "website",
"title": "Google",
"image": [{"url": "http://www.google.de/images/google_favicon_128.png"}
],
"updated_time": "2012-12-19T15:26:32+0000",
"id": "438699604740"
}
I am just wondering, why there are two different object IDs for the same URL and why do I need for the one an acces_token and not for the other?
The question is, how to get the right Data and the right ID throug the API? Or are there any restrictions to get these Data from a URL?
Thanks for help!

Facebook: identify object id and type by url

I want to get the id and type of a Facebook object based on its URL.
My goal is to identify if a certain URL is a Facebook Event (for example https://www.facebook.com/events/258629027581347).
So if I had the object-id of that object I could do the following FQL query and know that if I get a result the object is an Event:
select eid from event where eid = 258629027581347
The problem is getting the object-id based only on the URL. I do not want to parse the id from the URL because there is no guarantee that the format of the URL will remain the same in the future. I want to find a way to do it through one of Facebook's API's.
After searching for a while, I found the following suggestions for how to do this, but unfortunately none of them work:
FQL query from the object_url table - the query yields no results:
SELECT url, id, type, site FROM object_url WHERE url = "https://www.facebook.com/events/258629027581347"
Use the graph api:
https://graph.facebook.com/https://www.facebook.com/events/258629027581347
This returns a JSON object containing only the URL - no id.
Use the graph api with ?ids= like this:
https://graph.facebook.com/?ids=https://www.facebook.com/events/258629027581347
This returns the following JSON, also no id:
{
"https://www.facebook.com/events/258629027581347": {
"id": "https://www.facebook.com/events/258629027581347",
"metadata": {
"connections": {
"comments": "https://graph.facebook.com/https://www.facebook.com/events/258629027581347/comments?access_token=AAACEdEose0cBADzSuuyJWohIwkXuvQGJUsIlSJz04J4nzKqqQXTvGiPXf4YDBPuh0rdyXgSWnWcJpN3X3GaATVLjG6UmZBiHKmcxCWwZDZD"
},
"type": "link_stat"
}
}
}
What am I missing here?
Thanks!
To my knowledge, there isn't an API method at this time that takes a Facebook URL and tells you what it is. The only way to go about this is to parse the URL and look for the last element and pass this to https://graph.facebook.com/258629027581347?metadata=1&access_token=XXXX
It's a noble goal that you are trying to build a future-proof Facebook application, but I don't think that is a possibility at this time. The Facebook platform is still evolving. There is less of a guarantee that the api methods will remain constant than the url struture.

How do I get the permalink of a specific Facebook Social Plugin Comment through the Graph API?

Consider the following piece of dummy data returned from the Graph API for Facebook's Commenting Social Plugin:
{
"id": "387539086359_14842802",
"from": {
"name": "Manja Elis",
"id": "1168990251"
},
"message": "http://www.facebook.com/pages/Manja-Elis/151029671610040",
"created_time": "2010-11-24T07:06:06+0000",
"comments": {
"data": [
{
"id": "494442921359",
"from": {
"name": "J Reigy T II",
"id": "100001234540335"
},
"message": "~ www.jareta.name ~",
"created_time": "2011-01-30T00:04:30+0000"
}
],
"count": 1
}
}
How can I generate the permalink to this specific comment so that it can be bumped to the top of the discussion?
I know that the first id# "387539086359_14842802" is the ID of the comment thread as a whole, but now I need the specific ID of the actual first comment so that I can properly link to it. The problem is, that 3rd piece of ID information is nowhere to be found.
What I find funny is that the reply comment with id# "494442921359" is the correct ID for that reply, but there is no equivalent offered for the original post - why??? Worse yet, Facebook ignores links to any comments that aren't the first in a new sub-thread so linking to the reply instead is useless to me.
So to clarify:
Comment id of first post in the thread is : 387539086359_14842802_????
Comment id of the reply to this post would be: 387539086359_14842802_494442921359 but unfortunately FB ignores reply IDs so it is useless to me.
Can anyone tell me how I programatically get this ???? ID for permalink generation purposes?