FQL Filter user Table By name - facebook

It says in the FQL user Documentation that there are 4 indexable fields (marked with *):
name
third_party_id
uid
username
But when I perform a query like this:
SELECT uid
FROM user
WHERE name = "Mark Zuckerberg"
I get an error:
{
"error": {
"message": "Your statement is not indexable. The WHERE clause must contain
an indexable column. Such columns are marked with * in the
tables linked from
http://developers.facebook.com/docs/reference/fql ",
"type": "NoIndexFunctionException",
"code": 604
}
}
What am I missing here? Is this a bug? How can I filter an FQL query on the user table by name?

Awaiting response from FB on this bug, but meanwhile there is a workaround.
The indexable column name works in the profile table and can return its id field, which corresponds to the uid column in the user table, e.g.
SELECT first_name FROM user WHERE uid IN (SELECT id FROM profile WHERE name="Mark Zuckerberg")

Related

FQL NoIndexFunctionException 604 page_fan

I used FQL query:
SELECT uid FROM page_fan WHERE page_id = <page_id>
it returns me this error:
{
"error": {
"message": "Your statement is not indexable. The WHERE clause must contain an indexable column. Such columns are marked with * in the tables linked from http://developers.facebook.com/docs/reference/fql ",
"type": "NoIndexFunctionException",
"code": 604
}
}
on this site : http://developers.facebook.com/docs/reference/fql/page_fan
all columns that i used are indexed.
what am i doing wrong?
You can no longer get a list of users who like a page using FQL. This is done so by design.
If you look at the reference for fql/page_fan you can see that uid is the only column that is fully indexed, whereas the other indexed columns are only partially indexed. This means that you need to use uid in conjunction with the other partially index columns.
This will work
SELECT uid FROM page_fan WHERE uid = A AND page_id = B
Whereas this will not
SELECT uid FROM page_fan WHERE uid = A
Also see "Querying Users who 'like' my Facebook Page", which deals with what you are trying to do.

Why facebook album id is zero in FQL?

I am using FQL. I am using the following set of query to get info about album,
SELECT aid,src_small from photo where pid='100000244468314_1600187'
i get the following result,
{
"data": [
{
"aid": "0",
"src_small": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash3/545289_450190444999100_1364645489_t.jpg"
}
]
}
Then i gave the following query to get the album name and owner,
SELECT aid, owner, name, object_id FROM album WHERE aid="0"
But i get the following,
{
"data": [
]
}
Why is album id 0? and why it returns None? Please help. I am new to FQL
Try this query instead:
SELECT aid, owner, name, object_id FROM album
WHERE object_id IN
(SELECT album_object_id FROM photo where pid='100000244468314_1600187')
It looks like aid and pid fields are on their way to be deprecated in exchange for the object_id fields.

Getting Facebook Events using fql

Trying to retrieve facebook events through fql using the query below. I am unable to get venue details other than "id".
fql?q=SELECT name,description, pic_small,pic_big, eid,venue,location from event WHERE eid in (SELECT eid FROM event_member WHERE uid = me())
output :
{
"data": [
{
"name": "HappyHour",
"description": "Let's have fun !!!",
"pic_small": "http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yy/r/XcB-JGXohjk.png",
"pic_big": "http://profile.ak.fbcdn.net/static-ak/rsrc.php/v2/yn/r/5uwzdFmIMKQ.png",
"eid": ......,
"venue": {
"id": .......
},
"location": "The Crab Pot Seattle"
}
]
}
The graph api doc says "The venue where the event being queried is being held. Contains one or more of the following fields: street, city, state, zip, country, latitude, and longitude." but I don't see any of these except venue id.
Do I have to make another request to graph API to get the venue location details? Is there a better way to get the location details in one query itself?
You can get the locations for events using this FQL Multiquery.
This will get your events and information about their venues. You'll have to write a script on your end to combine them into something usable.
fql?q={
"event_info":
"SELECT name,description, pic_small,pic_big, eid,venue,location
FROM event WHERE eid IN
(SELECT eid FROM event_member WHERE uid = me())",
"event_venue":
"SELECT name, username, page_id, location
FROM page WHERE page_id IN
(SELECT venue.id FROM #event_info)"
}
Facebook changed the default encoding for events sometime in April. It used to be that all location data always used to be returned. Since then only the id of the location has been returned.

Get user name of comment in comments table FQL

I am getting Facebook comments data for particular posts using FQL. FQL returns only fromid however i need fromname as well. I am using batch request for getting comments of 50 posts at same time.
My query is
SELECT object_id,post_id,fromid,time,text,id,reply_xid,post_fbid,is_private FROM comment WHERE post_id='".$postID."'
How can I do this?
you need to make an additional query, something like this:
$multiQuery_postInfo = array(
"posts" => "SELECT post_id, actor_id, message, message_tags, likes, comments, share_count, attachment, action_links, type FROM stream WHERE source_id=$pageID",
"users" => "SELECT uid, username, first_name, last_name, profile_url, pic FROM user WHERE uid IN (SELECT actor_id FROM %23posts)"
);

FQL - getting photo record given pid

I am trying to do something very simple - getting a 'photo' record for a given pid. I am using:
SELECT pid,aid,owner,src_small,src_small_height,src_small_width,src,src_height,src_width,src_big,src_big_width,src_big_height,link,caption,created,modified,object_id FROM photo WHERE pid = '2622555765931507709'
I always get an empty result with no error. What am I doing wrong? I have tried the exact same request but with a 'WHERE aid = '' and that works fine..
This is the result from the GraphAPI: GraphAPI
{
"error": {
"type": "QueryParseException",
"message": "Some of the aliases you requested do not exist: 2622555765931507709"
}
}
Something must go wrong with your photo id. Can you give me the album id? Are you sure that the photo you are looking for exists