The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
Difference between revisions of "PHP"
m (Text replacement - "http://forum.iopus.com/" to "https://forum.imacros.net/") |
|||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | 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. | 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 <nowiki>http://your-address.com/?</nowiki>''macro=''yourmacro&''keyword=''yourkeyword | The script can be started remotely via a URL in the form <nowiki>http://your-address.com/?</nowiki>''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 | + | 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 | <?php | ||
− | |||
− | |||
− | |||
$iim1 = new COM("imacros"); | $iim1 = new COM("imacros"); | ||
− | $s = $iim1-> | + | $s = $iim1->iimOpen("-runner"); |
− | $s = $iim1->iimSet(" | + | $s = $iim1->iimSet("keyword", $_GET["keyword"]); |
$s = $iim1->iimPlay($_GET["macro"]); | $s = $iim1->iimPlay($_GET["macro"]); | ||
Line 17: | Line 17: | ||
echo $s; | echo $s; | ||
echo "extract="; | echo "extract="; | ||
− | echo $iim1-> | + | echo $iim1->iimGetExtract; |
− | $s = $iim1-> | + | $s = $iim1->iimClose(); |
?> | ?> | ||
− | + | Notes: | |
+ | * You can use the [[iimGetExtract]] command to return complete performance monitoring data and display it. Please see this [[Get-Response-Times.vbs|response time measurement VBS macro]] for details. | ||
+ | * '''Note: [[iimRunner]] is required if your web server process runs in a restricted user account.''' In this case you need to [[Web_Scripting#Running_iMacros_under_a_restricted_user_account_.28ASP.2FASP.NET.2FPHP.29|launch iMacros in an unrestricted account via iimRunner]]. iimRunner must be started manually or via task scheduler before running the script. Otherwise iimOpen ("-runner") returns an error code. | ||
+ | |||
+ | === 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 [https://forum.imacros.net/viewtopic.php?f=8&t=7865&p=23438#p23428 here]. |
Latest revision as of 12:30, 20 November 2018
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 $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(); ?>
Notes:
- You can use the iimGetExtract command to return complete performance monitoring data and display it. Please see this response time measurement VBS macro for details.
- Note: iimRunner is required if your web server process runs in a restricted user account. In this case you need to launch iMacros in an unrestricted account via iimRunner. iimRunner must be started manually or via task scheduler before running the script. Otherwise iimOpen ("-runner") returns an error code.
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.