Question

I'm trying to make a fql multy query using the PHP SDK. This is my code

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;
}

And this always returns an exception with no message

[04-May-2012 20:22:26 UTC] PHP Notice: Undefined property: FacebookApiException::$getMessage in C:\Program Files (x86)\Zend\Apache2\htdocs\wordpress\wp-content\plugins\all-in-one-event-calendar\lib\plugins\A1ecFacebookConnectorPlugin.php on line 120 [04-May-2012 20:22:26 UTC]

i'm obviously doing something wrong, what could that be?

Was it helpful?

Solution

Ok i found how to do this, you must use queries as a parameter, not 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;
}

OTHER TIPS

Your problem is you are trying to call $e->getMessage which does not exist. Your code on line 120 should read:

error_log( print_r( $e, true ) );

If you have problems with the multiquery, you could do this as a single query:

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

I've been able to get a query running like this three SELECTs deep. Four SELECTs seems to be too much.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top