0

somehow my FQL request won't work in PHP. In the Graph API Exporer the Query works fine. This is my main code:

$params = array( 'method' => 'fql.query', 'query' => "SELECT friend_count FROM user WHERE uid = me()", ); // graph api request for user data $request = new FacebookRequest( $session, 'GET', '/me', $params ); $response = $request->execute(); // get response $graphObject = $response->getGraphObject()->asArray(); // print profile data echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>'; 

This is Facebooks Error:

Fatal error: Uncaught exception 'Facebook\FacebookAuthorizationException' with message 'Unsupported method, fql.query' in /vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequestException.php:104 Stack trace: #0 /vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequest.php(268): Facebook\FacebookRequestException::create('{"error":{"mess...', Object(stdClass), 400) #1 /www/htdocs/app/facebook.php(97): Facebook\FacebookRequest->execute() #2 {main} thrown in /vendor/facebook/php-sdk-v4/src/Facebook/FacebookRequestException.php on line 104 (Path names changed)

1 Answer 1

1

Try replacing

$request = new FacebookRequest( $session, 'GET', '/me', $params ); 

with

$request = new FacebookRequest( $session, 'GET', '/fql?q=SELECT%20friend_count%20FROM%20user%20WHERE%20uid%20%3D%20me()'); 

Have a look at https://developers.facebook.com/docs/technical-guides/fql/#read

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome, altho there is a little mistake (your last ' is after q= not at the end of the array) it worked perfectly. Thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.