facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.17k stars 1.96k forks source link

graph api explorer: php sdk doesn't generate code with correct fields #1111

Open slownet opened 5 years ago

slownet commented 5 years ago

You may compare generated PHP code with javascript code sample. :)

PHP SDK tab:

try {
  // Returns a `FacebookFacebookResponse` object
  $response = $fb->get(
    '/app',
    '{access-token}'
  );
} catch(FacebookExceptionsFacebookResponseException $e) {
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(FacebookExceptionsFacebookSDKException $e) {
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}
$graphNode = $response->getGraphNode();

SDK JavaSchript:

FB.api(
  '/app',
  'GET',
  {"fields":"feed{id,story,attachments.limit(10){description,description_tags,media,target,title,type,url,subattachments}}"},
  function(response) {
      // Insert your code here
  }
);

P.S. in all PHP code samples you're using ->getGraphNode() method. But only ->getBody() or ->getDecodedBody() methods returning responding data.