1

我正在尝试使用 PHP SDK 进行 fql 多查询。这是我的代码

try {
    $fql = array( 
        "query1" => "SELECT uid2 FROM friend WHERE uid1 = me()",
        "query2" => "SELECT name, url, pic FROM profile WHERE id IN (SELECT uid2 FROM #query1)"
    );
    //$fql = "SELECT uid2 FROM friend WHERE uid1 = me()";
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api( array(
        'method' => 'fql.multiquery',
        'query' => $fql,
    ) );
} catch ( FacebookApiException $e ) {
    error_log( print_r( $e->getMessage(), true ) );
    $user = NULL;
}

这总是返回一个没有消息的异常

[04-May-2012 20:22:26 UTC] PHP 注意:未定义的属性:C:\Program Files (x86)\Zend\Apache2\htdocs\wordpress\wp-content\plugins\all- 中的 FacebookApiException::$getMessage in-one-event-calendar\lib\plugins\A1ecFacebookConnectorPlugin.php 在第 120 行 [04-May-2012 20:22:26 UTC]

我显然做错了什么,那会是什么?

4

2 回答 2

6

好的,我找到了如何执行此操作,您必须将queries其用作参数,而不是query

try {
    $fql = array( 
        "query1" => "SELECT uid2 FROM friend WHERE uid1 = me()",
        "query2" => "SELECT name, url, pic FROM profile WHERE id IN (SELECT uid2 FROM #query1)"
    );
    //$fql = "SELECT uid2 FROM friend WHERE uid1 = me()";
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api( array(
        'method' => 'fql.multiquery',
        'queries' => $fql,
    ) );
} catch ( FacebookApiException $e ) {
    error_log( print_r( $e->getMessage(), true ) );
    $user = NULL;
}
于 2012-05-05T10:03:48.743 回答
1

你的问题是你试图打电话给$e->getMessage不存在的电话。您在第 120 行的代码应为:

error_log( print_r( $e, true ) );

如果您对多查询有疑问,您可以将其作为单个查询执行:

$fql = "SELECT name, url, pic FROM profile WHERE id IN 
        (SELECT uid2 FROM friend WHERE uid1 = me() )";

$user_profile = $facebook->api( array(
    'method' => 'fql.query',
    'query' => $fql,
) );

我已经能够得到一个像这三个 SELECT 一样深的查询。四个 SELECT 似乎太多了。

于 2012-05-04T21:07:21.083 回答