diff --git a/IronWorker.class.php b/IronWorker.class.php index fb8a854..310f4d9 100644 --- a/IronWorker.class.php +++ b/IronWorker.class.php @@ -199,8 +199,9 @@ public function getCodeDetails($code_id, $project_id = ''){ /** * Uploads your code package - * @param string $project_id - * @param string $filename this file will be launched as worker + * + * @param string $project_id Project ID or empty string + * @param string $filename This file will be launched as worker * @param string $zipFilename zip file containing code to execute * @param string $name referenceable (unique) name for your worker * @return mixed @@ -222,12 +223,10 @@ public function postCode($project_id, $filename, $zipFilename, $name){ "oauth" => $this->token, "class_name" => $name, "options" => array(), - "access_key" => $name); + "access_key" => $name + ); $sendingData = json_encode($sendingData); - - // For reference to multi-part encoding in php, see: - // http://vedovini.net/2009/08/posting-multipart-form-data-using-php/ $eol = "\r\n"; $data = ''; $mime_boundary = md5(time()); @@ -298,6 +297,12 @@ public function deleteSchedule($project_id, $schedule_id){ return $this->apiCall(self::DELETE, $url, $request); } + /** + * Get information about all schedules for project + * + * @param string $project_id Project ID or empty string + * @return mixed + */ public function getSchedules($project_id){ $this->setProjectId($project_id); $this->setJsonHeaders(); @@ -307,9 +312,30 @@ public function getSchedules($project_id){ } /** - * @param string $project_id - * @param string $name - * @param array $payload + * Get information about schedule + * + * @param string $project_id Project ID or empty string + * @param string $schedule_id Schedule ID + * @return mixed + * @throws InvalidArgumentException + */ + public function getSchedule($project_id, $schedule_id){ + $this->setProjectId($project_id); + if (empty($schedule_id)){ + throw new InvalidArgumentException("Please set schedule_id"); + } + $this->setJsonHeaders(); + $url = "projects/{$this->project_id}/schedules/$schedule_id"; + + return json_decode($this->apiCall(self::GET, $url)); + } + + /** + * Schedule task + * + * @param string $project_id Project ID or empty string + * @param string $name Package name + * @param array $payload Payload for task * @param int $delay delay in seconds * @return string posted Schedule id */ @@ -318,9 +344,11 @@ public function postScheduleSimple($project_id, $name, $payload = array(), $dela } /** - * @param string $project_id - * @param string $name - * @param array $payload + * Schedules task + * + * @param string $project_id Project ID or empty string + * @param string $name Package name + * @param array $payload Payload for task * @param int $start_at Time of first run in unix timestamp format. Example: time()+2*60 * @param int $run_every Time in seconds between runs. If omitted, task will only run once. * @param int $end_at Time tasks will stop being enqueued in unix timestamp format. diff --git a/examples/testBasic.php b/examples/testBasic.php index 56f12fe..a246cf4 100644 --- a/examples/testBasic.php +++ b/examples/testBasic.php @@ -1,7 +1,7 @@ debug_enabled = true; diff --git a/examples/testBasicShedule.php b/examples/testBasicShedule.php index 67205b5..cfa092b 100644 --- a/examples/testBasicShedule.php +++ b/examples/testBasicShedule.php @@ -1,7 +1,7 @@ debug_enabled = true; @@ -22,7 +22,12 @@ $start_at = time()+3*60; # Run task every 2 minutes 10 times -$iw->postScheduleAdvanced($project_id, $name, $payload, $start_at, 2*60, null, 10); +$schedule_id = $iw->postScheduleAdvanced($project_id, $name, $payload, $start_at, 2*60, null, 10); + +# Get schedule information +$schedule = $iw->getSchedule($project_id, $schedule_id); +echo "Schedule:\n"; +print_r($schedule); echo "\ndone\n"; diff --git a/examples/testBasicSimplest.php b/examples/testBasicSimplest.php index 67dfa8d..5d2b890 100644 --- a/examples/testBasicSimplest.php +++ b/examples/testBasicSimplest.php @@ -1,7 +1,7 @@ debug_enabled = true; diff --git a/examples/testFFmpeg.php b/examples/testFFmpeg.php index 3bf592a..d4e67e1 100644 --- a/examples/testFFmpeg.php +++ b/examples/testFFmpeg.php @@ -1,7 +1,7 @@ debug_enabled = true; diff --git a/examples/testPDO.php b/examples/testPDO.php index d2dfca1..e9fc65e 100644 --- a/examples/testPDO.php +++ b/examples/testPDO.php @@ -1,7 +1,7 @@ debug_enabled = true; diff --git a/examples/testRedis.php b/examples/testRedis.php index 65d5fb6..33a0f71 100644 --- a/examples/testRedis.php +++ b/examples/testRedis.php @@ -1,7 +1,7 @@ debug_enabled = true; diff --git a/examples/testTwitter.php b/examples/testTwitter.php index b04b618..09c4427 100644 --- a/examples/testTwitter.php +++ b/examples/testTwitter.php @@ -1,7 +1,7 @@ debug_enabled = true;