嗨,在我的新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.
}
谢谢!
我最终通过使用批处理请求解决了该问题,并在页面完成加载后(使用AJAX)产生了在后台运行的作业。这似乎已经成功了!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句