I want to store my result as just location name, i found the result as an array but it can't stored in my database, it print only a name 'array' in my database
try {
$user6 = $fb->get('/me?fields=location');
$user6 = $user6->getGraphNode()->asArray();
//echo $user6->location->name;
$user6->location->name;
echo "<pre/>";print_r($user6);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
// When Graph returns an error
echo 'Graph returned an error: ' . $e->getMessage();
session_destroy();
// if access token is invalid or expired you can simply redirect to login page using header() function
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
For save my result in my databse, my code is below:
$location= $user6 ['location'];
echo $location;
mysql_query("insert into newmember(location) values('$location')") or die(mysql_error());
my result is :
Array
(
[location] => Array
(
[id] => 101889586519301
[name] => Dhaka, Bangladesh
)
[id] => 1589273127757008
)