Retrieve posts and comments from Facebook wall with Open Graph/FQL - facebook

I am finding many difficults while trying to do a rather simple task using facebooks' api (FQL and Open graph).
The task is what the title says getting post-list and relative comments from a user wall i tried via FQL and open graph without results :
Approach 1) open graph
simple me/feed query returns almost what I want but it includes self-references results such as
{
"id": "1614018744_10200682419255581",
"from": {
"name": "Franco Martinelli",
"id": "1614018744"
},
"story": "\"UNO\" on his own status.",
"privacy": {
"value": ""
},
"type": "status",
"created_time": "2013-06-16T13:49:58+0000",
"updated_time": "2013-06-16T13:49:58+0000"
},
and i cant seem to find what to filter to exclude those records or if i am supposed to filter on my end
Approach 2) With this query in FQL
{"q1":"SELECT post_id, actor_id,target_id, message FROM stream
WHERE source_id=me()
AND type in (46,56,80,128,247) AND created_time < 1371254400 LIMIT 250",
"q2":"SELECT text from comment where post_id IN (SELECT post_id FROM #q1)"}
i get my own posts but not post made by others and also the limit clause works in mysterious way from what i have read around.
I have used twitter api's without a single problem,i cant believe i have to go through all this mess for a simple request.

Here are the two queries. You need to include type = 'newsfeed' then that would bring up posts made by your friends,just like your news feed on facebook.com
getpost: ("SELECT actor_id, created_time, likes, post_id, message FROM stream WHERE filter_key IN (SELECT filter_key FROM stream_filter WHERE uid=me() AND type='newsfeed') AND is_hidden = 0"),
users: ("SELECT id, name, url, pic FROM profile WHERE id IN (SELECT actor_id FROM #getpost)")
http://fbdevwiki.com/wiki/FQL:stream

Related

Giving Multiple Ids for stream in facebook FQL

select post_id, message from stream where source_id IN (..., ..., ...) LIMIT 500
I'm using this fql query but it is returning just few posts. While the below query is returning more than 200 posts.
select post_id, message from stream where source_id = ... LIMIT 500
but giving same id with other id is returning 4 to 5 posts.
I know fql support is not available in v2.0 but still I want to do this using fql.
This seems strange... Have you tried doing this via pure Graph API? What kind of objects are you using as source_ids?
GET /?ids={object_id_1},{object_id_2},{object_id_3}&fields=feed.fields(id,message).limit(100)

How to retrieve FB comments/shares for a specific URL

I would like to retrieve the text,author of comments or shares made for a specific url.
I have for instance the following target : http://www.graphemeride.com/blog/comment-j-ai-triche-aux-golden-blog-awards
I can retrieve the number of comments and shares with FQL :
SELECT
url, share_count , comment_count, comments_fbid
FROM
link_stat
WHERE
url="http://www.graphemeride.com/blog/comment-j-ai-triche-aux-golden-blog-awards"
I get the following result :
{
"data": [
{
"url": "http://www.graphemeride.com/blog/comment-j-ai-triche-aux-golden-blog-awards",
"share_count": 27,
"comment_count": 26,
"comments_fbid": 357167807708699
}
]
}
My plan was to use the comment FQL query to retrieve the different comments.
SELECT
id, text
FROM
comment
WHERE
object_id="357167807708699"
However I get an empty result dataset.
I added the required access token, but kind of understood that I can only get comments I made about this object, not public comments or shares.
Is there an alternative way to get access to what people publicly said about an url ?
The comment count on the link_stat table is the for the number of comments on the SHARES of this link and not the number of comments on the comments plugin on that page itself.
Whereas the comments table returns you the number of comments from the comments plugins on that page.
As your page isn't using any fb comments plugin, you don't get any comments back.

Facebook FQL returns no result, while GraphAPI does

I'm trying to get Facebook user information by username. I'm trying to make following FQL request:
SELECT first_name, last_name FROM user WHERE username="Google"
I got no data in response:
{
"data": [
]
}
Same query works OK for other usernames:
SELECT first_name, last_name FROM user WHERE username="c1egger"
This gives me:
{
"data": [
{
"first_name": "Paul",
"last_name": "Dmitryev"
}
]
}
I've tried to use GrapAPI with following request:
/Google?fields=id,name
And got the result:
{
"name": "Google",
"id": "104958162837"
}
Also, I'm getting same problem, when trying to query by userid.
Major part of my application uses FQL, so I'd like to figure out why FQL not working, before starting complex porting to FQL.
They are not the same request...
/Google?fields=id,name
That request doesn't check in "User" table, that's why you can't retrieve user "google" with '104958162837' id.
facebook.com/c1egger and facebook.com/Google are not the same type of page.
select name from page where page_id=104958162837
or
select page_id from page where username='Google'
Gives you the same result as the graph api.
FQL works, but it's more complex that GraphApi to use.
Facebook Query Language, or FQL, enables you to use a SQL-style interface to query the data exposed by the Graph API. It provides advanced features not available in the Graph API.

Facebook FQL stream query only returning 4 items

I am trying to retrieve all Photos from a user's stream.
SELECT post_id, actor_id, target_id, message, created_time
FROM stream
WHERE filter_key in (SELECT filter_key FROM stream_filter WHERE uid = me()
AND type='newsfeed')
AND type = 247
AND is_hidden = 0
ORDER BY created_time DESC
This only returns 4 results, and they are very recent posts. If I try to include a 'created_time < 1360993620' clause, it returns zero results. Is there any reason why this query does not go very far into the past?
It looks like an easier way to do what I'm trying to do is to use the Graph API to pull a user's home feed and then filter it for only the photo posts:
GET /me/home?filter=app_2305272732

How to retrieve Facebook likes with descriptions

How can I get list of facebook likes (pages that user has liked ) with descriptions
Im using /me/likes object, but it won't give me likes descriptions. I understand I can use FQL with "WHERE page_id in (LIST_OF_IDS)" - or request for every like separately
Is there any way to get it with one request ?
Yes, this can be done via FQL with the following query:
SELECT name, description FROM page WHERE page_id IN (SELECT page_id
FROM page_fan WHERE uid=me())
https://developers.facebook.com/tools/explorer?fql=SELECT%20name%2C%20description%20FROM%20page%20WHERE%20page_id%20IN%20(SELECT%20page_id%20FROM%20page_fan%20WHERE%20uid%3Dme())%0A
Or this way using the Graph API: USER_ID?fields=likes.fields(description)
If it is possible with the Graph API, don´t take FQL. The Graph API is usually faster and easier:
me/likes?fields=id,name,description
Result (from my account):
"data": [
{
"id": "244993732224805",
"name": "Jón Gnarr",
"created_time": "2012-12-06T00:35:43+0000"
},
{
"id": "161086703983",
"name": "Design Shack",
"description": "We only offer the cream of great design, filtering through lots of the redesigns that occur every day across the Internet, and cataloguing the greatest projects out there - perfect for getting that spark of creativity going again.\n\t\nRegular articles will teach you new techniques for creating your own designs, and daily community news ensures that you're up to date with the latest developments elsewhere.\n\t\nIf you want to be updated every time a new design or tutorial is added, you can subscribe:\n\t\nDesign Shack RSS Feed\nhttp://feeds.feedburner.com/designshack\n\nTwitter\nhttp://twitter.com/designshack",
"created_time": "2012-12-04T14:40:08+0000"
},
{
"id": "274797542535942",
"name": "Chasing Aurora",
"description": "Chasing Aurora is an explorative 2D aerial action game about the dream of flight.\n\nDrop from the cliff and ride the wind from peak to peak. Fight for the beacon of light with up to three friends in the hostile environment of the Alps.",
"created_time": "2012-12-04T12:07:13+0000"
},
...