PHP

(Copy URL in PhpBB Forum Format - Info)

From iMacros

Jump to: navigation, search

Here's how to use PHP with iMacros

Code sample

This PHP examples shows how to start iMacros from a PHP script from Apache or IIS running on a Windows Server.

The script can be started remotely via a URL in the form http://your-address.com/?macro=yourmacro&keyword=yourkeyword It displays the results on the website after the iMacros run (iimPlay) is completed. This method can be used to call iMacros remotely from another machine, for example a monitoring server running on the Linux OS or to collect the data from several monitoring stations to a central unit.

   <?php 
 	    $fso = new COM('Scripting.FileSystemObject'); 
 	    $fso = NULL;
 
 	    $iim1 = new COM("imacros");
 	    $s = $iim1->iimInit("-runner");
     
 	    $s = $iim1->iimSet("-var_keyword", $_GET["keyword"]);
 	    $s = $iim1->iimPlay($_GET["macro"]);
     
 	    echo "iimplay=";
 	    echo $s;
 	    echo "extract=";  
   	    echo $iim1->iimGetLastExtract;
     
 	    $s = $iim1->iimExit();
   ?>

Notes:

  • You can use the iimGetLastExtract command to return complete performance monitoring data and display it. Please see this response time measurement VBS macro for details.
  • Note: iimRunner must be started manually or via task scheduler before running the script. Otherwise iimInit ("-runner") returns an error code.

Using a string builder

  • When creating a "macro string" ("CODE:...") that is then passed to iimPlay(), consider using a string builder instead of string concatenation as explained here.
Retrieved from "http://wiki.imacros.net/PHP"
Personal tools