1

It's my first question on stackoverflow. I made this application and it works fine for posting a photo to a user's wall once he visit the app page, But what I really want is to post many photos in a scheduled way (at a specific time like 12 Feb 2013 10:00 pm) to his wall and all users wall

I made a MySQL database that contains a table for users' ID, and a table for posts' info and time.

What can I do next?

include ("../facebook/facebook.php") ; 

$facebook = new Facebook(array(
  'appId'  =>  APP_ID ,
  'secret' =>  APP_SECRET ,
  'fileUpload' => true,
));
$user = $facebook->getUser();

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

if ($user) {
    $facebook->setFileUploadSupport(true);



            $photo ="images/image1.jpg" ; 
        $message= "My message ";
            $ret_obj = $facebook->api('/me/photos', 'post', array(
                                             'source' => '@' . $photo,
                                             'message' => $message,
                                             )
                                          );

  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl(array(
  'scope' => 'read_stream, publish_stream, photo_upload')  
  );
}
4

1 回答 1

0

@kareem:简单来说,您可以有一个循环语句。

  for($i=0;$i<$upperLimit;$i++)
 {
   $photo ="images/image".$i."jpg" ; 
    $message= "My message ";
        $ret_obj = $facebook->api('/me/photos', 'post', array(
                                         'source' => '@' . $photo,
                                         'message' => $message,
                                         )
                                      );
  } 

$upperLimit 是 limit ,直到您计划将图像发布到用户墙上。

注意:您可以在某个位置拥有一组图像image1...imagen,这样您就可以在用户墙上发布时循环图像

如果需要,您可以在 for 循环中添加一个计时器以延迟一些时间

于 2013-02-12T13:10:51.977 回答