嗨,所以在我的新 Facebook 应用程序中,我尝试为屏幕上的用户加载一系列个人资料图片。问题是,它需要的时间太长了。这就是我目前正在做的获取图片的方法——我还能做些什么来加快速度吗?执行大约需要 10 秒以上。
我正在使用灯箱,只有在单击屏幕上的第一张图片后才真正需要加载其他图片,但不知道该怎么做。
//First off we need to get some profile pics for the user:
$getuseralbumsurl = "https://graph.facebook.com/". $row['FB_ID'] ."?fields=albums&access_token="
. $access_token;
$getuseralbums = json_decode(file_get_contents($getuseralbumsurl));
$getuseralbums = $getuseralbums->albums;
foreach( $getuseralbums->data as $album ){//Getting profile pics for user.
if($album->type == "profile"){ //get profile picture album
$albumid = $album->id;
$photosurl = "https://graph.facebook.com/" . $albumid . "/photos?access_token=". $access_token ."&limit=3";
$profilephotos = json_decode(file_get_contents($photosurl));
$counter = 0;
foreach( $profilephotos->data as $image ){
if($counter == 3)//we only want 3 photos from the album.
break;
if($lowerbound == 0)
$photosurlarray['group1'][] = $image->source;
else if($lowerbound == 1)
$photosurlarray['group2'][] = $image->source;
else
$photosurlarray['group3'][] = $image->source;
$counter++;
}
break;//we don't need anymore albums.
}
谢谢!