Sunday 15 February 2015

php - How to echo a JSON output -



php - How to echo a JSON output -

below json code got after logging in facebook. how can extract info json ? tried next ones, not working.

$user = json_decode(file_get_contents($graph_url)); stdclass object ( [id] => 725426940865193 [email] => stargijo2@gmail.com [first_name] => gijo [gender] => male [last_name] => varghese [link] => https://www.facebook.com/app_scoped_user_id/725426940865193/ [locale] => en_gb [name] => gijo varghese [timezone] => 5.5 [updated_time] => 2014-09-27t13:47:05+0000 [verified] => 1 ) echo $user['email']; //not working

it's object, not array. need utilize object syntax:

echo $user->email;

if want access array must pass true sec parameter json_decode():

$user = json_decode(file_get_contents($graph_url), true); echo $user['email'];

php json

No comments:

Post a Comment