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 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.

 	    $iim1 = new COM("imacros");
 	    $s = $iim1->iimOpen("-runner");
 	    $s = $iim1->iimSet("keyword", $_GET["keyword"]);
 	    $s = $iim1->iimPlay($_GET["macro"]);
 	    echo "iimplay=";
 	    echo $s;
 	    echo "extract=";  
   	    echo $iim1->iimGetExtract;
 	    $s = $iim1->iimClose();


Using a string builder

  • When creating a "macro string" that is then passed to iimPlay() or iimPlayCode(), consider using a string builder instead of string concatenation as explained here.