facebook fql query album table not working with graph api php
$fql = 'SELECT name,aid,photo_count,owner FROM album WHERE owner='.$userId; $fql = 'SELECT aid,owner,name FROM album WHERE owner IN (SELECT uid1 FROM friend WHERE uid1 = 100002278102636 LIMIT 1 )';
I am using my codeigniter application to upload photo to an album which will be named current date.Creating album and all other uploads are working fine,but when i tried to select album name from album table using owner field its returning an empty array.But above query works fine with facebook test query widget
i used API like this
$ret_obj1 = $this->facebook->api(array( 'method' => 'fql.query', 'query' => $fql, ));
what am i doing wrong...Thanks in advance
My guess is that this is a permission issue. To get these results, you need to be authenticated as a user and have the user_photos and friends_photos permission in your access token. If you don't, the FQL query will return a result and Facebook will filter that result out before it is given to your app, giving an empty data set.
The other possibility is your access token does not belong to user 100002278102636. If that is the case, then the friend subquery will fail.
Also, you should be using album_object_id now instead of aid. It appears that the aid field (and pid) will be removed in November.
Have you tried running your $fql query through urlencode? You'll notice that the one on facebooks graph explorer is encoded but yours is not
$ret_obj1 = $this->facebook->api(array( 'method' => 'fql.query', 'query' => urlencode($fql), ));
As an aside - this query:
$fql = 'SELECT aid,owner,name FROM album WHERE owner IN (SELECT uid1 FROM friend WHERE uid1 = 100002278102636 LIMIT 1 )';
You are selecting uid1 WHERE uid1 = a known value? Why not just do
$fql = 'SELECT aid,owner,name FROM album WHERE owner = 100002278102636 )';