Using the docmail simple api from php
-------------------------------------
No doubt apache is best for running PHP but as my webserver is IIS this includes additional instructions
on setting php up on IIS (steps 1-5) as well using the docmail api (step 6). I guess on apache you would
need to find a way to install NuSoap although possibly later php has SOAP built in.
Caveat: I am a .net programmer so make no apologies for breaking probably 101 php rules in the sample - it
is an example to get you up and running.
1) No doubt apache is best for php but as my webserver is IIS I have to use it. It can still be installed
either manually or the best (simplest) way I found was to use the Microsoft PHP on IIS installer (!).
I went for the FastCGI option when installing it.
http://blogs.iis.net/bills/archive/2006/09/19/How-to-install-PHP-on-IIS7-_2800_RC1_2900_.aspx
2) Install the NuSoap PHP wrapper from
http://sourceforge.net/project/showfiles.php?group_id=57663&package_id=53241&release_id=552239
3) Amend the php include paths to include the nusoap libraries
Look here http://www.modwest.com/help/kb5-98.html
or I amended c:\program files\php\php.ini to include the following (added the c:\program files\php\ bit)
include_path = ".;c:\php\includes;c:\program files\php\"
4) (IIS Only) Amend the fast cgi timeouts to cope with docmail proofing
c:\windows\system32\inetsrv\fcgiext.ini
and make sure it contains
ActivityTimeout=240
RequestTimeout=240
5) PHP should now be up and running. Add something like "test.php" in the webserver path
and add something like the following in there, browse to the file and it should process the request
correctly.
print "Hello World";
?>
6) Here is my sample PHP code using the NuSoap SOAP wrapper
Undefined or FirstClass or StandardClass - to get the BEST benefit use StandardClass
$eAddressNameFormat = "FullName";//How the name appears in the envelope address
";
print "Contents of file:
";
print_r($contents);
print "
";
}
error_reporting(E_ALL);
// Increase php script server timeout
set_time_limit(240);
// Setup array to pass into webservice call
$arr = array(
'sUsr' => $sUsr,
'sPwd' => $sPwd,
'sMailingName' => $sMailingName,
'sCallingApplicationID' => $sCallingApplicationID,
'bColour' => $bColour,
'bDuplex' => $bDuplex,
'eDeliveryType' => $eDeliveryType,
'sTemplateFileName' => $sTemplateFileName,
'eAddressNameFormat' => $eAddressNameFormat,
'bTemplateData' => $contents,
'sNameTitle' => $NameTitle,
'sFirstName' => $FirstName,
'sLastName' => $LastName,
'sAddress1' => $sAddress1,
'sAddress2' => $sAddress2,
'sAddress3' => $sAddress3,
'sAddress4' => $sAddress4,
'sPostCode' => $sPostCode,
'bProofApprovalRequired' => $ProofApprovalRequired
);
if ($debug) print "About to call SendLetterToSingleAddress
";
$result = $client->call('SendLetterToSingleAddress',$arr);
print "Checking for errors
";
$err = $client->getError();
if ($err) {
print '
' . htmlspecialchars($client->request, ENT_QUOTES) . ''; echo '
' . htmlspecialchars($client->response, ENT_QUOTES) . ''; // Display the debug messages echo '
' . htmlspecialchars($client->debug_str, ENT_QUOTES) . ''; } } catch (Exception $e) { print "PROBLEM:" .$e->getMessage() ."