我正在使用 Facebook Open Graph 来检索有关我管理的页面的信息,其中包括:
$user_profile_accounts = $facebook->api('/me/accounts','GET');
foreach ($user_profile_accounts['data'] as $account) {
...
}
之后,我想使用接收到的信息使用jquery.dd填充选择下拉列表。如果我通常在 foreach 中使用它,它将创建一个这样的选择:
<select name="accmenu" id="accmenu">
<option data-description="<?php echo $account['category'] ?>" data-image="https://graph.facebook.com/<?php echo $account['id']; ?>/picture" value="<?php echo $account['id'] ?>"><?php echo $account['name'] ?></options>
</select>
因为每个帐户都在循环中。这不是我想要的,而是所有帐户的下拉列表是期望的结果。如果我将选择放在 foreach 之外,我如何遍历收到的数据?数据:
{
"data": [
{
"category": "Artist",
"name": "Alexandra Dinu Official",
"access_token": "BAAIGQYZBqjIABAPu8IEsuBqFVegB1ZCto61tvMIPVzUZC4JITosIHEr6dSHvYLsehcDYsCuBqlw13KepOsq1Eq1EDVqc0DFPm5sktlkjfZC8qoZAvQKyKxBdnVc2ihmBiu7nPYZC1oYznmcgm21iPCMrFTbO2OX6Vu5nSIZBvsaxTYWiyWISVixU0mTBmmi76DC8JV5FQRbZBzY7x2FRFsgQ5pZCrPStC06ZB3WhoSZBHZAZAMzs88norJYfH",
"id": "116376655202954",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
{
"category": "Fictional character",
"name": "Potato Pete",
"access_token": "BAAIGQYZBqjIABAKk4mM2jkVMk2miMjHkUWjZC75UDNnEPUZBNWz4ZBN3FqXbmKZAGSTyocAUzmehdIgUVSuRbr6rOg9Bq28rfsITrNT1kM7fcYFBfMA1yC9bG7c3JvaIZCgkQeXwVHx5pRJw1NFnCTOcFEmpAVlFOsAE2fy28k7zHpAky3wDQjsWD6KLEkqi0C44ZAhR3QQILCaFM9BwVn7Vpau2WUnbRHrZAjf4RofGUYEb9frEX3v1",
"id": "497232410336701",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
{
"category": "Event planning/event services",
"name": "Mariage Fest",
"access_token": "AAAIGQYZBqjIABAKqeomUfYZAkZAwINIZCiEBBUqw1DB6WM04090f5PrWNqzjX6SvF9Ld4l70ghwZAJYqAb2S587uQCm0cK1ZAaZABH1IDqUTlbOUZBD56EPxEnvYyEH1NM0ZD",
"id": "311822035526927",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
},
{
"category": "Restaurant/cafe",
"name": "Pub Restaurant Wales Pitești",
"access_token": "BAAIGQYZBqjIABAEYYZA4bvhnFnGEy2pfwUjDwuZA3ZBCDur4ItNJhcxh4uFeAatjO3zf4q6FioK1QyXWHTQTc4vQ5tPltCgrhXhN75TeGCY6ntONDwE0VHmBrTFXMZAsNmKZCx6QAfHWbsWADsNzOhtY7lhDznC9uH0dsfIzh2nQyZCQXZAAcoKGpnlArJjtud5iUxDqC3rlZA3N1xvXaeiwOH6CZCM8IySEZChZCRkP4C9NLeHzcuB4qlJV",
"id": "252842318171796",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
}
]
}
这是 PHP 还是 JavaScript 的问题?我非常感谢任何指导。先感谢您。