Facebook FQL returns no result, while GraphAPI does - facebook

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.

Related

Get highest scores from facebook Graph API

I'm using facebook graph API in my Unity Application. What I'm trying to do is to retrieve the users using my application and show the first 20 ones ordered by score.
In the example project "friend smash" there's the following graph API call:
FB.API("/app/scores?fields=score,user.limit(20)", Facebook.HttpMethod.GET, ScoresCallback);
This, as far as I know, gets 20 users who are using my application. Due to the poor graph API documentation I can't understand if user.limit(20) just returns 20 random users, or ordered with some criteria.
If this call returns random users, do I have to send one query for each friend, sort them by score and show only the first 20 ones to get a proper ranking? (I guess it would be quite query heavy though)
In Facebook Graph Explorer use following GET request to receive friends with score (descending order):
app/scores?fields=score&limit=20
It should return following Json:
{
"data":
[
{
"score": 1,
"user":
{
"name": "1st Name",
"id": "first_id"
}
},
{
"score": 0,
"user":
{
"name": "2nd Name",
"id": "2nd_id"
}
}
]
}
https://developers.facebook.com/docs/games/scores/#read-many-scores:
You can read the set of scores for a player and their friends by issuing an HTTP GET request to /APP_ID/scores with the user access_token for that app. The user_friends permission is required in order to view friends' scores. This returns a list of scores for a player and friends who have authorized the app. The list is sorted by descending score value, so it returns friends with the highest scores first.
(Highlighting by me.)

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.

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

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

OAuthException "An unexpected error has occurred" when trying to query count field of comments_info table with FQL

We have a Facebook app that uses the FB comments social plugin. We're trying to automatically pull the total number of comments that have been posted using that app.
We've tried using this query:
SELECT count FROM comments_info WHERE app_id = 210218945658186
However, this returns the following information:
{
"error": {
"message": "An unexpected error has occurred. Please retry your request later.",
"type": "OAuthException",
"code": 2
}
}
If we query fields other than the count field, the result is properly returned. This query:
SELECT xid, app_id, updated_time FROM comments_info WHERE app_id = 210218945658186
Returns the following results:
{
"data": [
{
"xid": null,
"app_id": 210218945658186,
"updated_time": 1315413930
}
]
}
Does anyone know how we could fix the unexpected error? We've tried this query several times over the past few days, so it's not an intermittent issue. We tried the solution at http://facebook.stackoverflow.com/questions/9708969/event-query-using-fql-returns-oauthexception-an-unknown-error-has-occurred using columns from the comments_info table, but that didn't work.
We've also looked at other options to total the number of comments in the app. The answer at How to list all comments in my domain doesn't work because we have a variable number of subpages the comments plugin is used on.

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"
},
...