Facebook hometown graph api
I am currently getting data from a users profile when they login through facebook, I want to store this data for signup process on my site. When accessing "hometown" it lists it as one such as:
London, Westminster, United Kingdom
The hometown is in an array as follows:
> [h开发者_Python百科ometown] => Array
> (
> [id] => 000000000
> [name] => London, Westminster, United Kingdom
> )
I access the town name by using the code
<?php echo $me['hometown']['name']; ?>
Would it be possible to have each part single? So that I could have, town, country etc
I am using Facebook php SDK Thanks :)
You can use:
$hometown=explode(",",$me['hometown']['name']);
echo $hometown[0]; //London
echo $hometown[1]; //Westminster
echo $hometown[2]; //United Kingdom
edited: changed to explode as "split()" is deprecated as of php 5.3
精彩评论