我正在尝试查询某个页面的所有相册,并让每张专辑封面照片。下面是我返回空结果的代码。
我可以单独创建两个查询而不会出现问题,因此它不是权限问题。
$album_fql = "SELECT aid, owner, name, object_id, cover_pid, cover_object_id
FROM album
WHERE owner = 'xxxxxxx'";
$albumpic_fql = "SELECT pid, src_small
FROM photo
WHERE pid IN (SELECT cover_pid FROM #query1)";
$album_param = array(
'method' => 'fql.multiquery',
'queries' => '{"query1":"' . $album_fql . '", "query2":"' . $albumpic_fql . '"}');
$album_fqlResult = $facebook->api($album_param);
print_r($album_fqlResult);
有什么想法吗?
答案 0 :(得分:1)
您可以在嵌套查询中执行此操作,而不是作为多查询。
SELECT pid, src_small
FROM photo
WHERE pid in (SELECT cover_pid FROM album where owner={page id here})
例如,这是我从CocaCola的Facebook页面获得的专辑封面列表
SELECT pid, src_small
FROM photo
WHERE pid in (SELECT cover_pid FROM album where owner=40796308305)
LIMIT 5
返回:
{
"data": [
{
"pid": "40796308305_2143765",
"object_id": 110516463305,
"src_small": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-snc1/6570_110516463305_40796308305_2143765_6253354_t.jpg"
},
{
"pid": "40796308305_8753877",
"object_id": "10150500888203306",
"src_small": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/398389_10150500888203306_40796308305_8753877_1814220329_t.jpg"
},
{
"pid": "40796308305_8751674",
"object_id": "10150500434253306",
"src_small": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/407475_10150500434253306_40796308305_8751674_1040781388_t.jpg"
},
{
"pid": "40796308305_8742570",
"object_id": "10150498588158306",
"src_small": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/396541_10150498588158306_40796308305_8742570_1378170213_t.jpg"
},
{
"pid": "40796308305_8742259",
"object_id": "10150498546173306",
"src_small": "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-snc7/402667_10150498546173306_40796308305_8742259_287537096_t.jpg"
}
]
}
如果要尝试多重查询,请尝试命名从索引0开始而不是1的查询。 query0和query1这是C#SDK允许的唯一方式,也许php SDK也需要它。
答案 1 :(得分:1)
终于明白了。我不得不将查询合并为1个变量并转义单引号。
$queries = '{
"query1" : "SELECT aid, name, cover_pid FROM album WHERE owner = \'xxxxxxxxxxx\'",
"query2" : "SELECT aid, images FROM photo WHERE pid IN (SELECT cover_pid FROM #query1)"
}';