开发者

Facebook hometown graph api

开发者 https://www.devze.com 2023-01-16 08:40 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消