Perform batch functions using PHP API

  1. <?php
  2. require_once("panacea_api.php");
  3. $api new PanaceaApi();
  4. $api->setUsername("demouser");
  5. $api->setPassword("demouser");
  6.  
  7. $file "../generic/mybatch.csv";
  8.  
  9. $result $api->batch_create("My batch name"$file);
  10.  
  11. if($api->ok($result)) {
  12.     /* Batch created ! */
  13.     
  14.     $batch_id $result['details'];
  15.     
  16.     echo "Batch created with ID {$batch_id}\n";
  17.     
  18.     /* Let's create another one from XLS */
  19.     
  20.     $file "../generic/mybatch.xls";
  21.     
  22.     $result $api->batch_create("My second batch"$file0false'xls');
  23.     
  24.     if($api->ok($result)) {
  25.         echo "XLS Batch created!\n";
  26.         
  27.         /* Give it a moment to parse */
  28.         sleep(1);
  29.         
  30.         $status $api->batch_check_status($result['details']);
  31.         
  32.         
  33.         
  34.         
  35.         
  36.  
  37.         if($status['details']['status'== 32// Is it currently paused and waiting?
  38.             $api->batch_start($result['details']);
  39.             
  40.             /* Let's wait a while and see if it's done */
  41.             
  42.             sleep(2);
  43.             
  44.             $status $api->batch_check_status($result['details']);
  45.             
  46.         }
  47.         
  48.     }
  49.     
  50.     
  51. }
  52.  
  53. ?>