Airikr
Airikr

Reputation: 6436

Get data from Facebook Graph API with JSON

I want to print the ID of the comment (eg. 10151828637085391_33268745) from this page but I don't know how to get pass the URL. After I had decoded the data with JSON and printed it out with var_dump() it looks like this:

array
  'http://gallery.erik-edgren.nu/photo/P1220672' => 
    array
      'comments' => 
        array
          'data' => 
            array
              ...
          'paging' => 
            array
              ...

So far so good. I have tried to write $array->http://gallery.erik-edgren.nu/photo/P1220672->comments->data->id but the // make the whole string to a comment on the website. I have even tried to add \ before I print the / ($array->http:\/\/galle...) but I'm getting the following error message:

Parse error: syntax error, unexpected ':' in ...

How can I fix this problem?

Thanks in advance.

Upvotes: 0

Views: 270

Answers (1)

William
William

Reputation: 3529

I believe you'd need to do $array['http://gallery.erik-edgren.nu/photo/P1220672']['comments']['data']['id'], since it's an array and not an object.

Upvotes: 1

Related Questions