抱歉,这似乎是一个愚蠢的问题,但我意识到我有很多东西要学习 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>';
?>