2013-04-11 48 views
0

我一直在玩FB SDK和一些用于显示FB相册的示例,但这些示例比我想要的要复杂得多。我想要做的就是为单张专辑设置专辑ID并拉入内容。就是这样,我可以在后面设计所有样式,我只需要查看一张专辑的内容并为每张照片添加标题即可。显示来自单个预定义专辑的内容

我正在尝试创建一个WordPress相册,我可以很容易地创建小部件的基础,但是当涉及到API时我就迷失了方向。

有没有我忽略的例子呢?

有谁知道如何做到这一点?

回答

0

希望这给你一个提示;)

<? 

if (empty($_GET['album'])) { 

//get all albums of page 
    $graph_url = "https://graph.facebook.com/PressPlayPrague/albums?  fields=id,link,name,cover_photo&limit=500"; 
    $albums = json_decode(file_get_contents($graph_url)); 
     $counted = sizeof ($albums->data); // get the number of albums for later use 

//output all albums of given page 
for($c=0; $c<$counted; $c++){ 
    echo ("<div class='wrapper' <a href='?album=".$albums->data[$c]->id."'><div class='stack'><div style='width:180px; height:120px; display:inline-block; background-image:url(https://graph.facebook.com/".$albums->data[$c]->id."/picture?width=300&height=200); background-repeat:no-repeat;'> </div></div><div class='caption'>".$albums->data[$c]->name."</div></a></div>"); 
}; 

}else{ 

     //get the album pictures replace the $_GET[album] with specific ID and remove the if clause to get only one album 
    $pic_url = "https://graph.facebook.com/".$_GET[album]."/photos?fields=picture&limit=500"; 
    $pictures = json_decode(file_get_contents($pic_url)); 
    $countpic= sizeof ($pictures->data); // get the number of pics for later use 
for($p=0; $p<$countpic; $p++){ 
echo ("<img style='width:250px; max-height:167px;' src='https://graph.facebook.com/".$pictures->data[$p]->id."/picture' alt='".$pictures->data[$p]->id."'>"); 

    }; 

} 

?> 
+0

太感谢你了,我没想到它会如此简单! – 2013-04-12 13:44:23

相关问题