这个FQL Multiquery有什么问题吗?没有结果

时间:2012-09-02 10:17:52

标签: facebook facebook-graph-api facebook-fql

{
        "query1": "SELECT aid, cover_pid, name, created FROM album 
            WHERE owner = 166125753465316  AND name != \'Wall Photos\' ORDER BY created DESC LIMIT 3",

        "query2": "SELECT pid, src, src_small, src_big, caption FROM photo 
            WHERE aid IN (SELECT aid FROM #query1)  ORDER BY created DESC LIMIT 5"
}

使用以上$查询,然后:

$param  =   array(
             'method'    => 'fql.multiquery',
             'queries'     => $queries,
             'callback'  => ''
            );
            $fqlResult   =   $facebook->api($param);

            var_dump($fqlResult);

给我一​​个空数组?我做错了什么?

我想抓住所有者= ...的相册,并从每张专辑中获取5张照片。

我可以使用单个查询执行此操作,但是加载页面确实需要很长时间!

4 个答案:

答案 0 :(得分:1)

在这种情况下,我认为你不需要多重查询,只需像这样改变

SELECT pid, src, src_small, src_big, caption FROM photo 
     WHERE aid IN (SELECT aid FROM album  WHERE owner = me()  ORDER BY created DESC )  
     ORDER BY created DESC LIMIT 5

你也可以使用这个GRAPH API

me?fields=albums.fields(cover_photo,created_time,photos.limit(5).fields(link))

这里是链接

http://developers.facebook.com/tools/explorer?method=GET&path=me%3Ffields%3Dalbums.fields%28cover_photo%2Ccreated_time%2Cphotos.limit%285%29.fields%28link%29%29

答案 1 :(得分:1)

您是否尝试过此图形API查询 -
USER_ID?fields = albums.fields(name,photos.limit(5).fields(id,name),id,cover_photo,created_time)
这来自最近推出的图形api字段扩展功能 - https://developers.facebook.com/docs/reference/api/field_expansion/

答案 2 :(得分:1)

我刚试过这个,并在查询中用me()代替ID,它可以正常工作。当我尝试查找您的ID 166125753465316时,它会抛出“Unsupported get request error”。这可能是你的问题。

我能够使用有效用户或应用访问令牌在评论中使用PAGE_ID获取数据。

其他几条评论:您应该使用object_id代替aidpid。这些都有待批准。

其次,此查询仅返回您返回的三张相册中的5张最新照片。要分别获得5张照片,您需要执行以下操作:

{
    "albums": "SELECT object_id, cover_object_id, name, created FROM album 
        WHERE owner = me()  AND type != 'wall' ORDER BY created DESC LIMIT 3",

    "album1": "SELECT object_id, src, src_small, src_big, caption FROM photo 
        WHERE album_object_id IN (SELECT object_id FROM #albums LIMIT 1 OFFSET 0)
        ORDER BY created DESC LIMIT 5",

    "album2": "SELECT object_id, src, src_small, src_big, caption FROM photo 
        WHERE album_object_id IN (SELECT object_id FROM #albums LIMIT 1 OFFSET 1)
        ORDER BY created DESC LIMIT 5",

    "album3": "SELECT object_id, src, src_small, src_big, caption FROM photo 
        WHERE album_object_id IN (SELECT object_id FROM #albums LIMIT 1 OFFSET 2)
        ORDER BY created DESC LIMIT 5"

}

答案 3 :(得分:1)

尝试删除查询中的换行符,只使用空格作为分隔符。

试试这个编辑过的fql

{
    "query1": "SELECT aid, cover_pid, name, created FROM album WHERE owner = 166125753465316 AND name != \'Wall Photos\' ORDER BY created DESC LIMIT 3",
    "query2": "SELECT pid, src, src_small, src_big, caption FROM photo WHERE aid IN (SELECT aid FROM #query1)  ORDER BY created DESC LIMIT 5"
}