Facebookの友だちのリストをドロップダウンリストに表示するスクリプトが、Facebookのアプリケーションにあります。以下のコードで、私はユーザーの友達をつかむことができますが、ユーザーIDのみを取得しています。 this linkでPHPでjson戻り値を取得する方法?
$api_key = 'xxx';
$secret = 'xxx';
include_once 'facebook.php';
$facebook = new Facebook($api_key, $secret);
$friends = $facebook->api_client->friends_get();
foreach ($friends as $friend)
{
echo $friend;// returns only the friend's ID and not name but i want to show the name
$url="https://graph.facebook.com/".$friend."/";
$res=file_get_contents($url);
}
私は、ユーザーの名前を取得し、ドロップダウンリストに表示します。どのように私はそれをつかんで、$url
から名前だけをエコーすることができますか?
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"gender": "male",
"locale": "en_US"
}
誤った答え。 json_encodeの代わりにjson_decodeを使用する必要があります。 – Gajus
**デコード**と思う;) – singles
はい - 私のタイプミス – bensiu