我开发了一个小型的脸上式应用程序,每天将照片上传到一张相册,每天都会在照片中粘贴倒计时,直到活动当天。 我试图实现每日上传和发布到我保存的每个用户的墙,但它似乎每次都失败..应用程序请求离线访问和发布流..它保存access_token和用户ID。当cron作业每天运行时,它会成功上传1或2个,然后会找到错误505页面找不到。继承我的代码。关于如何改变它以使其起作用的任何想法?
$app_id = "XXXXXXXXXXXXXXXXXXXX";
$app_secret = "XXXXXXXXXXXXXXXXXXXXXXXXX";
$sel=mysql_query("SELECT * FROM faceinhole WHERE imagen!='' AND activo=1");
while($as=mysql_fetch_array($sel)){
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true,
'domain' => "mydomain.com"
));
extract($as);
if(is_file($imagen)){
$future=mktime(20,0,0,10,14,2011);
$now = time();
$timeleft = $future-$now;
$daysleft=floor($timeleft/60/60/24);
list($w,$h)=getimagesize($imagen);
$imagen2=imagecreatefromjpeg($imagen);
imagepng($imagen2,$imagen.".png");
$imagen3=imagecreatefrompng($imagen.".png");
$color = imagecolorallocate($imagen3, 58, 221, 2);
imagettftext ( $imagen3 , 64 , 0 , 124 ,315 , $color , "Gotham-Ultra.ttf" , "$daysleft" );
$prefijo2 = substr(md5(uniqid(rand())),0,6);
$connum="fotos/".$prefijo."_feis_num.png";
imagepng($imagen3,$connum);
$facebook->setFileUploadSupport(true);
if($album_id!=""){
$album_uid=$album_id;
}else{
$album_details = array(
'access_token' => "$access_token",
'message'=> "Mis camisetas de los Juegos Panamericanos Guadalajara 2011. Viste la camiseta Panamericana para tu perfil de facebook aquí -> http://facebook.com/galeriasgdl?sk=app_$app_id",
'name'=> 'Mis camisetas Panamericanas'
);
try{
$create_album = $facebook->api('/me/albums', 'post', $album_details);
}catch(Exeption $e){
}
$album_uid = $create_album['id'];
mysql_query("UPDATE faceinhole SET album_id='$album_uid' WHERE user_id='$user_id'")or die(mysql_error());;
}
$photo_details = array(
'access_token' => "$access_token",
'message'=> "Estoy a $daysleft días de los Juegos Panamericanos Guadalajara 2011. Viste la camiseta Panamericana para tu perfil de facebook aquí -> http://facebook.com/galeriasgdl?sk=app_$app_id"
);
$file=$connum;
$photo_details['image'] = '@' . realpath($file);
try{$upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);}catch(Exeption $e){}
}
}
答案 0 :(得分:1)
即使经过同意,自动发布也不受政策小组的欢迎。