If I enter the following queries in the Facebook Graph Explorer both return a result with one value:
Case 1)
SELECT user_id from like where object_id =584xxxxxxx637
{
"data": [
{
"user_id": 100xxxxxxxxxxx57
}
]
}
in PHP code:
$result = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT user_id from like where object_id=584xxxxxxx637'));
var_dump($result);
returns the expected result:
array(1) { [0]=> array(1) { ["user_id"]=> string(15) "100xxxxxxxxxxx57" } }
However, for the following similar query, I also get a valid result from the graph explorer but not from PHP:
Case 2)
SELECT page_id from page_fan where uid=me() and page_id=400xxxxxxxx095
Result in Graph Explorer:
{
"data": [
{
"page_id": 400xxxxxxxx095
}
]
}
in PHP
$result = $facebook->api(array(
'method' => 'fql.query',
'query' => 'SELECT page_id from page_fan where uid=me() and page_id=400xxxxxxxx095'));
var_dump($result);
Output:
array(0) { }
The user is logged into Facebook for the session (hence the graph query returns a valid result)
I've no idea why!
Started off looking at this again today and suddenly it works, I have no idea why but presumably there is some caching going on somewhere. I'm happy at least that it works :)