Determine Object_ID of a URL to use with the Facebook Open Graph - facebook

I am trying to learn how to use the Facebook Open Graph API and have a question on how to determine the object_id of my site. I need this object_id so that I can do other queries, such as I want to get a list of users who have liked my site within a given time period.
Based on other Stackoverflow questions I have seen that I should be able to run this query to get the object_id
select id from object_url where url in ('www.bubbasgameroom.com', 'bubbasgameroom.com')
When I run that query it comes back with an empty result. When I run the following query, I see that my page has been liked 21 times
select total_count from link_stat where url in ('www.bubbasgameroom.com', 'bubbasgameroom.com')
What am I missing here? Any help will be greatly appreciated.
Thanks!

Most likely the url should be identical to the og:url meta tag if used on your website. Also you need to append the http:// part for it to work. For example this would work:
SELECT url,site,id
FROM object_url
WHERE url IN (
'http://developers.facebook.com',
'http://www.imdb.com/'
)
Result:
[
{
"url": "http://developers.facebook.com",
"site": "developers.facebook.com",
"id": 113167538713703
},
{
"url": "http://www.imdb.com/",
"site": "www.imdb.com",
"id": 6903354771
}
]
But this doesn't:
SELECT url,site,id
FROM object_url
WHERE url IN (
'developers.facebook.com',
'www.imdb.com/'
)

Related

How to get the Facebook Share count for a given URL?

Given a particular URL, how can I get the Facebook Share count for it?
There is one way to get the count, i know that platforms like sharedcount.com are using this:
https://api.facebook.com/method/links.getStats?urls={your-url}/&format=json
I highly suggest not using FQL anymore, it is deprecated and no longer available in v2.1+ of the Graph API: https://developers.facebook.com/docs/apps/changelog#v2_1_deprecations
Edit: This is deprecated, but there is another possibility: Get FB likes, shares and comments for a URL using PHP - with no limit
The easiest way to do this is to fire off a request to the Graph API.
The following query will select:
like_count
total_count
share_count
click_count
comment_count
https://graph.facebook.com/fql?q=SELECT%20like_count,%20total_count,%20share_count,%20click_count,%20comment_count%20FROM%20link_stat%20WHERE%20url%20=%20%27http://imdb.com%27
{
"data": [
{
"like_count": 62024,
"total_count": 191031,
"share_count": 93544,
"click_count": 71308,
"comment_count": 35463
}
]
}
Just replace the google.com with whatever URL you want to get the information for.

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

FQL like, share, comment count accuracy

Often it seems fql number for a given url like, share, comment, total counts seem to be off.
For example this url
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine
FQL shows:
share_count: 18377
like_count: 16215
comment_count: 8840
total_count: 43432
The graph api shows very different numbers, and if you check facebook widget count on the url itself it has a totally different count.
Anyone knows what is going on and how to get accurate numbers.
When querying link_stat with url you supplied we see the following:
select comment_count, like_count, share_count, total_count
from link_stat where url = 'http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine/'
{
"data": [
{
"comment_count": 10,
"like_count": 55,
"share_count": 18,
"total_count": 83
}
]
}
But when querying link_stat with parent url of site france24.com we see exactly your numbers (weel slightly changed of course, but almost the same). So check you query - maybe you cut the url somehow in you request?
select comment_count, like_count, share_count, total_count
from link_stat where url = 'http://www.france24.com/'
{
"data": [
{
"comment_count": 8840,
"like_count": 16415,
"share_count": 18377,
"total_count": 43632
}
]
}
Perhaps my initial question was not clear, the issue was with 2 forms of the same url returning radically different results in fql, web facebook widget etc. the urls in question are
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine
and
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-ukraine/
The URLs are identical except the ending /
The facebook sees the url as a string. Is case sensitive and it matters how you pass it for url. So, for facebook, there are really two different urls :/ The same happens if someone writes Ukraine with "U".
http://www.france24.com/en/20140112-reporters-crimean-tatars-unending-exile-identity-ethnic-minority-muslims-central-asia-Ukraine

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.

facebook query pages sort on likes

I am looking for a way to query facebook pages that for example, have something to do with food.
Not to difficult ;)
$pages = $facebook->api('search?q=food&type=page');
But... I want to get the largest pages (most likes) of that category. Search get's close, but I can't influence the return order (I think).
I have been looking here: https://developers.facebook.com/docs/reference/fql/page/
to see if I can get it to work with a query, but it seems I can only query information about a specific page.
I have been looking for several solutions without succes. Is this even possible at all? Any help would be much appreciated!
How about this:
Make that request to "search?q=food&type=page", then take the results and iterate over them.
For each result make the following FQL query:
SELECT
name, username, fan_count
FROM
page
WHERE
page_id="ITERATION_PAGE_ID"
For example, the first result I get has the id "25255939006", the FQL will be:
SELECT name, username, fan_count FROM page WHERE
page_id="25255939006"
And the result is:
{
"data": [
{
"name": "Food",
"username": "",
"fan_count": 146291
}
]
}
Hope this is what you were after.