Monday, February 20, 2012

Using the JangoMail API in PHP

Since PHP 5 provided developers with the SoapClient class, it's a snap to consume SOAP-enabled web services in a PHP script.

This example demonstrates how to connect to the JangoMail API in order to get the email lists on your account. Download the source code for this example, insert your own JangoMail credentials, and you're ready to start integrating the JangoMail API with your php website.

// create a SoapClient object for the jangomail aPI
$client = 
    new SoapClient("http://api.jangomail.com/api.asmx?WSDL");

// set the parameter array for the
// Groups_GetList_String method
$param=array(
 'Username'=>'Your JangoMail Username',
 'Password'=>'Your JangoMail Password',
 'RowDelimiter'=>'<br/>',
 'ColDelimiter'=>' - ',
 'TextQualifier'=>''
); 

// using the JangoMail API
// call the Groups_GetList_String method
$result = $client->Groups_GetList_String($param);

// print the groups that were returned
print($result->Groups_GetList_StringResult);