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.
Related
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.
I'm developing an app that retrieves events via FQL from facebook Pages.
it happens sometimes that the owners of these pages do not create these events from the Page profile, but from their own profile and just link the event to the page as the field Venue (since the pages I'm looking for are public places)
is it possible via FQL or any other mean to get all the events ID that have as venue a specific facebook page ID??
now i can get all the events only if the page owners insert the events via the page profile with the following code:
$fql = "SELECT eid, creator, name, pic, timezone, start_time, end_time, location, description
FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid IN ($clubsstring) )
AND start_time > $today
AND start_time < $nextweek
ORDER BY start_time asc";
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
thanks
Luca
Well, you can indeed search based on venues, but that can only be a secondary condition since the venue field is not indexable.
This means that you first have to search based on eid (the only indexable field in the Event table), and then filter those results based on the venue.
The problem is that the venue field is an array, and the fields in it are not always there, for example one event might have this as venue:
"venue": {
"id": VENUE_ID
}
But another will have:
"venue": {
"street": "",
"city": "",
"state": "",
"country": ""
}
You should be able to get what you want with something like:
SELECT eid, creator, name, pic, timezone, start_time, end_time, location, description
FROM event
WHERE
((eid IN (SELECT eid FROM event_member WHERE uid IN ($clubsstring)))
OR
(eid IN (SELECT eid FROM event_member WHERE uid IN (OWNERS_IDS_STRING)))
AND
venue.id IN (VENUE_IDS_STRING))
AND start_time > $today
AND start_time < $nextweek
ORDER BY start_time asc;
I haven't tested this query, and you might need to modify it a bit to work, also you can use a different field of venue other than the id.
Hope this helps.
I use this, it´s currently working.
{"eventos":"SELECT start_time, end_time, name, eid, pic,venue.id, location, creator, description
FROM event WHERE eid IN (SELECT eid FROM event_member WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1=me() LIMIT 150)
OR uid = me() AND rsvp_status = 'attending') AND venue.id <>''
AND location <> '' AND location <> '#data'","lugares":"SELECT latitude,longitude
FROM place WHERE page_id IN (SELECT venue.id FROM #eventos)"}
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)"
);
I use this function to get photos from a facebook album. Please give advice why it returns blank space.
function getPhotos(aid) {
sql = 'SELECT pid, src_big, src_small FROM photo WHERE aid='+aid+' ORDER BY modified desc';
FB.api(
{
method: 'fql.query',
query: sql
},
function(response) {
console.log(response);
}
);
}
While posting the error would help, you should wrap the aid in quotes since it's a string field (ref):
sql = 'SELECT pid, src_big, src_small FROM photo WHERE aid="'+aid+'" ORDER BY modified desc';
Also make sure you have the right permission user_photos.
I have written a fql to get photo from facebook.
fql = 'SELECT caption, owner, pid, src_big, created
FROM photo
WHERE aid IN (SELECT aid
FROM album
WHERE owner IN (111111) )
LIMIT 1,10';
But I found sometimes the app cannot get the photo from the src_big column.
How to write a fql or any other methods to make sure the returned photo url (e.g.src_big) is accessible?
Taken from the Facebook API:
The URL to the full-sized version of
the photo being queried. The image can
have a maximum width or height of
720px. This URL may be blank.
I think your issue is that you don't always get a src_big image. You should also query for the src_small image, as a fallback. Also, you can add a default image of your own, so that if neither image is available or acceptable, you can just use your default image.
For example:
fql = 'SELECT caption, owner, pid, src_big, src_small, created
FROM photo
WHERE aid IN (SELECT aid
FROM album
WHERE owner IN (111111) )
LIMIT 1,10';
And then in your code, check for something like....
//Where results = photo results array...
for(var i = 0; i<results.length; i++){
if(results[i].src_big == null){
if(results[i].src_small == null){
//Use default image
}
else{
//Use src_small
}
}
else{
//use src_big
}
}