fql.multiquery 返回空数组

发布于 2024-12-23 09:45:28 字数 666 浏览 3 评论 0原文

我正在尝试查询页面的所有相册并获取每个相册的封面照片。下面是我返回空结果的代码。

我可以分别进行这两个查询而不会出现问题,因此这不是权限问题。

$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);

有什么想法吗?

I'm am trying to query all the photo albums of a page and get each albums cover photo. Below is the code I have that returns an empty result.

I am able to make both the queries separately without the problem, so it is not a permissions issue.

$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);

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吝吻 2024-12-30 09:45:28

您可以在嵌套查询中而不是作为多重查询来执行此操作。

SELECT pid, src_small 
FROM photo 
WHERE pid in (SELECT cover_pid FROM album where owner={page id here})

例如,这是我从可口可乐 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 也需要这样做。

you can do that in a nested query rather than as a multi query.

SELECT pid, src_small 
FROM photo 
WHERE pid in (SELECT cover_pid FROM album where owner={page id here})

for example here's the list of album covers I got from CocaCola's Facebook page

SELECT pid, src_small 
FROM photo 
WHERE pid in (SELECT cover_pid FROM album where owner=40796308305)
LIMIT 5

returned:

{
  "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"
    }
  ]
}

If you want to try your multiquery, then try to name the queries starting at index 0 instead of 1. e.g. query0 and query1 This is the only way the C# SDK allows it, maybe the php SDK requires that too.

满身野味 2024-12-30 09:45:28

终于想通了。我必须将查询合并到 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)"

}';

Finally figured it out. I had to merge the queries into 1 variable and escape the single quotes.

    $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)"

}';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文