1

I am trying to get the name of the person who has posted the post, but I don't understand how to get the name from the array.

Here is the full code: http://pastebin.com/88ADm5Uw

This is the line I have a problem with:

echo "FROM: " . print_r($post['from']) . '<br>';

This line returns two values(id and name) and I want to only print out the name. Please help!:

EDIT: Any way to get the profile picture?

2
  • What's $post? Where is it initialized? Can you get the information directly from `$_POST['from']? Commented Sep 29, 2013 at 16:04
  • 2
    What post? What person? What array? Commented Sep 29, 2013 at 16:04

2 Answers 2

1

Try this:

echo "FROM: " . print_r($post['from']['name']) . '<br>';

You can see the complete JSON here:

https://developers.facebook.com/tools/explorer?method=GET&path=me%2Fhome

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

2 Comments

Thanks for the answer! btw, do you know how i can get the date when the post was created, posted(the method in my code shows todays date)?
$post['created_time'] or $post['updated_time']. Did you click on the link I've mentioned in the answer? That has the complete json response.
1

$post['from'] is an array containing name and id. If you only want to print out the name, you could do something like echo $post['from']['name'] I believe.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.