好吧,所以我想弄清楚这一点。基本上,除了将封面照片添加到每个 DIVS 之外,我的一切都运行良好。基本上我有 2 个使用 FQL 的查询,这是我的代码。
$query =
'{"query1":"SELECT aid, cover_pid, name, description FROM album WHERE owner=$fbowner",
"query2":"SELECT src FROM photo WHERE pid IN (SELECT cover_pid FROM #query1)"}';
$fqlResult = $facebook->api(array(
'method' => 'fql.multiquery',
'queries' => $query));
$fql = $fqlResult[0]['fql_result_set'];
$covers = $fqlResult[1]['fql_result_set'];
$the_count = count($fql);
$i = 0;
foreach($fql as $value) {
$album_cover = $value['src'];
echo "<div class='fb_block'>";
echo "<a href='" . $url . "?action=list_pics&aid=" . $value['aid'] . "&album_name=" . $value['name'] . "'>";
echo "<img src='{$covers[$i]['src']}' border='1'>";
echo "</a>";
echo "<h3>".$value['name']."</h3>";
echo "<p>".$value['description']."</p>";
echo "</div>";
$i++;
}
现在效果很好,但是如果我把它放在混合中,除非我让 $i = 1,否则封面照片都会关闭。
$i = 0;
foreach($fql as $value) {
if($value['name'] != 'Wall Photos'){
$album_cover = $value['src'];
echo "<div class='fb_block'>";
echo "<a href='" . $url . "?action=list_pics&aid=" . $value['aid'] . "&album_name=" . $value['name'] . "'>";
echo "<img src='{$covers[$i]['src']}' border='1'>";
echo "</a>";
echo "<h3>".$value['name']."</h3>";
echo "<p>".$value['description']."</p>";
echo "</div>";
$i++;
}
}
如果我在混合中添加另一个 foreach,它会抓取所有封面照片并将它们粘贴到每个 div 中。那么,按顺序获取与相册节点关联的封面照片的最简单解决方案是什么?
提前致谢!