Reputation: 51
I'm new with PHP SDK Facebook, so sorry if that quesiton is stupid.
So, i have this code
SELECT name FROM user
WHERE current_location.country = 'Italy' AND
uid IN (
SELECT uid2 FROM friend WHERE uid1 = me()
)
That responses me:
{
"data": [
{
"name": "Matilde xxxx"
},
{
"name": "Samson xxxxxxxx"
},
{
"name": "Emanuela xxxxxxx"
}
]
}
I'm using this site to analyze how to manage the json :http://chris.photobooks.com/json/default.htm
i saw that if i want to have a request of the name of a friend i have to do that: root.data[5].name
so that is my php code :
$user_id = $facebook->getUser();
$all_friends = $facebook->api(array('method' => 'fql.query', 'query' => 'SELECT name FROM user
WHERE current_location.country = "Italy" AND
uid IN (
SELECT uid2 FROM friend WHERE uid1 = 1068943079
) '));
$val = 1;
echo $all_friends['data'][$val]['name'];
(is a test, i want to see the friend at key=1) but there is only white page... show nothing.. and if i do echo $all_friends i see Array.
Sorry if this is a stupid question, i know that i can use another method to do that..but i want to know how to do it with this way! Thank you, and sorry for my language.
That is all my code : CLICK HERE TO SEE MY CODE
Upvotes: 1
Views: 1329
Reputation: 22893
print_r($all_friends)
to check the structure of the arrayTry
echo $all_friends[$val]['name'];
$user != 0
.Place it under the if
statement
read_friendlists
permission$params = array(
'scope' => 'read_friendlists'
);
$loginUrl = $facebook->getLoginUrl($params);
Doc:
Upvotes: 1