Using the PHP PHP SDK, getGraphObject-> asArray () returns an object?

I call objects from Facebook of the new PHP SDK, and I break the objects as shown below, however, for two separate requests that I call the same, they do not return the same. The first query is returned as an array (hopefully). Second, it returns as an object, and for life I do not understand why.

$fb_session = new FacebookSession( $fb_session->getToken() );

// graph api request for user data
$fb_user_array = (new FacebookRequest( $fb_session, 'GET', '/me' ))->execute()->getGraphObject()->asArray();

echo "FB USER >> A" . $fb_user_array['id'];     // WORKS
echo "FB USER >> B" . $fb_user_array->id;       // FAILS

$picture_array = (new FacebookRequest( $fb_session, 'GET', '/me/picture?type=large&type=square&redirect=false' ))->execute()->getGraphObject()->asArray();

echo "FB PIC >> A " . $picture_array['url'];    // FAILS!!
echo "FB PIC >> A " . $picture_array->url;      // WORKS??
+4
source share
2 answers

It was a mistake in the SDK PHP, which since been fixed . Just download the latest version 4.0 and you won’t have to ask this anymore. :)

+2
source

. GET, fb , ... ( huh??). , API (fb - ), API fb, . , - , . , fb, .

0

Source: https://habr.com/ru/post/1547232/


All Articles