我在这里有这段代码,其中$friends
变量是一个输出如下的数组:
{
"id": "1149862205",
"name": "name",
"first_name": "first_name",
"last_name": "last_name",
"link": "https://www.facebook.com/username",
"username": "username",
"birthday": "07/12/1990",
"hometown": {
"id": "108618265828550",
"name": "name"
},
而$fbfriendlikes
变量由 id 生成$friends
并具有以下结构:
{
"data": [
{
"name": "Penelope-ns-test",
"category": "Community",
"id": "187099821418102",
"created_time": "2012-06-14T15:00:59+0000"
},
现在,我需要在
我的代码中打印所有$friends
类似于特定 id 的 id,如下所示:$fbfriendlikes
$friends = $facebook->api('/me/friends');
if (!empty($friends['data'])) {
$size = variable_get('facebook_graph_pic_size_nodes','square');
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
foreach ($friends['data'] as $data) {
$fbid = $data['id'];
$fbfriendlikes[$fbid]=$facebook->api('/'.$fbid.'/likes');
$fbname = $data['name'];
$path = $protocol . '://graph.facebook.com/' . $fbid . '/picture?type=' . $size;
$image = theme('image', array('path' => $path, 'alt' => $fbname));
if ($fbfriendlikes["id"] != 184759054887922) {
$return .= '<div class="fimage">'.$image.'</div>';
$link = '<a href="'.$protocol . '://www.facebook.com/profile.php?id='.$fbid.'" target="_blank">'.$fbname.'</a>';
$return .= '<div class="flink">'.$link.'</div>';
break;
}
}
}
我知道我必须做一个 foreach 循环,$fbfriendslikes
但我似乎无法让它工作。你能给我一个建议吗?