对不起,如果这看起来像一个愚蠢的问题,但我意识到我有很多东西要学习PHP。 我想知道我跳过什么,因为正如标题所说,我使用PHP的图片库从Facebook网站获取图像,但每次只拉出前25张图片,所有图片都是公开的,并由同一个人上传。 我正在使用从这个网站获取的教程: http://www.webdesignermag.co.uk/tutorials/facebook-image-gallery/
具体使用的代码是:
<?php
//Set the page name or ID
$FBid = 'ArazaArtesanias';
//Get the contents of a Facebook page
$FBpage = file_get_contents('https://graph.facebook.com/'.$FBid.'/albums');
//Interpret data with JSON
$photoData = json_decode($FBpage);
echo '<ul id="display-inline-block">';
foreach ( $photoData->data as $data )
{
echo '<li><a href="getphotos.php?album_id='.$data->id.'">
<img class="shadow" src="https://graph.facebook.com/'.$data->id.'/picture/" width=70 border=0 />
</a>';
echo '<br /><a href="getphotos.php?album_id='.$data->id.'">'.$data->name.'</a></li>';
}
echo '</ul>';
?>
对于个人相册画廊是这样的:
<?php
//Get the contents of the album data page
$rawAlbumData = file_get_contents('https://graph.facebook.com/'.$_GET['album_id'].'/photos');
//Interpret data with JSON
$photoData = json_decode($rawAlbumData);
echo '<ul id="display-inline-block">';
foreach ( $photoData->data as $data )
{
echo '<li><a href="'.$data->source.'" rel="lightbox" title="';
if (property_exists($data, "comments")) {
foreach ( $data->comments->data as $Cdata )
{
echo htmlentities('<li class="imgcomments">
<a href="http://www.facebook.com/people/@/'.$Cdata->from->id.'" target="_blank"> <img src="https://graph.facebook.com/'.$Cdata->from->id.'/picture"
align=left border=0 />
</a>
<a href="http://www.facebook.com/people/@/'.$Cdata->from->id.'" target="_blank">
<b>'.$Cdata->from->name.'</a>: </b>'.$Cdata->message.'<br />
<div align="left" style="padding-bottom:10px;">
<small> Posted '.timeSince(strtotime($Cdata->created_time)).' ago</small></div> </li>');
}
}
else {
echo 'There are no comments on this album';
}
echo '"><img class="shadow" src="'.$data->picture.'" width=70 border=0 /></a></li>';
}
echo '</ul>';
//Get data about the photo album
$rawCommentData = file_get_contents('https://graph.facebook.com/'.$_GET['album_id']);
//Interpret comment data with JSON
$commentData = json_decode($rawCommentData);
echo '<div class="comments">';
echo '<h2>Album Comments</h2>';
if ( $commentData->comments->data ) {
foreach ( $commentData->comments->data as $data )
{
echo ' <a href="http://www.facebook.com/people/@/'.$data->from->id.'" target="_blank"><b>'
.$data->from->name.'</a>: </b>'.$data->message.'<br/><div align="left" style="padding-bottom:10px;">
<small> Posted '.timeSince(strtotime($data->created_time)).' ago</small></div></li>';
}
}
else {
echo 'There are no comments on this album';
}
echo '</div>';
?>
答案 0 :(得分:1)
这与您的PHP代码无关;用于检索JSON数据的URL仅返回25个<data>
项(=图片。)
阅读Facebook API文档,了解如何一次性检索超过25张图片,或如何指定“偏移”(例如,您可以检索图片26-50。)