1

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?

Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
  • It looks like the error is occurring within the exception handler and it's not showing the output of what threw the exception. Can you try `var_dump`ing `$e` in your exception handler to see what that spits out? – Jimmy Sawczuk May 04 '12 at 20:43

2 Answers2

6

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;
}
Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
1

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.

cpilko
  • 11,792
  • 2
  • 31
  • 45
  • I was stupid, i just didn't save the file and i was accessing the property and not the method! :) Anyway i found a solution to do the multiquery, i'll post it, thanks for your help anyway – Nicola Peluchetti May 05 '12 at 10:03