1

I am grabbing info from Facebook's API about a certain user, using the /user_id/picture call, and I var_dump the response and see this:

var_dump($graphObject);

which gives me the response:

object(Facebook\GraphObject)#6 (1) { ["backingData":protected]=> object(stdClass)#8 (2) {   ["url"]=> string(112) "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xap1/t1.0-1/p200x200/115634790309_n.jpg" ["is_silhouette"]=> bool(false) } }

And as silly as it is, I can't figure out how to get that "url" string into a variable. I am new to this all, but I thought something would work like:

graphObject->url;

And I have tried a bunch of other things, can anyone help?

Cocorico
  • 2,319
  • 3
  • 22
  • 31
  • Does `$graphObject->url` work? If not what error do you get? – WizKid Jul 22 '14 at 05:20
  • This question may be useful: http://stackoverflow.com/questions/23541431/reading-data-from-facebook-graphobject – Brandon Gano Jul 22 '14 at 05:20
  • WizKid: No, that just gives me an empty string. – Cocorico Jul 22 '14 at 05:27
  • Brandon Gano: Unfortunately, I don't think that getProperty thing works with calls to /me/picture, I have tried that with getProperty('url') and whatnot, I just get errors. I think that's for objects cast as GraphUsers – Cocorico Jul 22 '14 at 05:29

1 Answers1

2

Once you get $graphObject, you can convert it into an array so you can access the objects in it, as follows:

// convert to array
$graphObject = $graphObject->asArray();

// echo URL
echo $graphObject['url'];
Niraj Shah
  • 15,087
  • 3
  • 41
  • 60