inwise - email marketing and newsletter software company
 
inwise Top Background
Arrow on Service
Home  -->  Email Marketing API  -->  Recipients Add Or Update Php

Recipients Add Or Update Php
Footer

Recipients Add Or Update Php

Operation Name: operation Name
Description: description

All actions require a valid user name and password using authenticaion header.
Show a raw xml example including the authentication header.

Service url : https://www.em-sender.com/ws/InwiseWebServices.asmx

Adding a reference to inwise web services

User Name:
Password:  
operation name :Recipients_AddOrUpdatePHP
email :
Groups ID
(separate with ',') :
fields values :
Field1:
Field2:
Field3:
Field4:
Field5:
Field6:
Field7:
Field8:
Field9:
Field10:
Field11:
Field12:
Field13:
Field14:
Field15:
Field16:
Field17:
Field18:
Field19:
Field20:
Field21:
Field22:
Field23:
Field24:
Field25:
Field26:
Field27:
Field28:
Field29:
Field30:
<?php
if ($_POST["postback"] == "true")
{
	addUpdateRecipient($_POST["email"],
	        $_POST["firstName"],
	        $_POST["lastName"],
	        array(325,326));
}

function addUpdateRecipient($email,$firstName,$lastName,$groups)
{
	// build the request
	$data = prepareXml($email,$firstName,$lastName,$groups);
	
	// set the web service url
	$url="https://www.em-sender.com/ws/InwiseWebServices.asmx";
	
	// initialize curl handle
	$ch = curl_init($url); 
	
	// set headers needed for the web service
	$headers=array(
		"SOAPAction:http://www.inwise.com/schemas/Recipients_AddOrUpdate",
		"Content-type: text/xml; charset=utf-8",
		"Content-length: ".strlen($data));
	curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
	
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable
	curl_setopt($ch, CURLOPT_TIMEOUT, 120); // time out

	// add POST fields - the request xml
	curl_setopt($ch, CURLOPT_POSTFIELDS,  $data); 

	// call the remote service
	$result = curl_exec($ch);

	$err = curl_error($ch);

	curl_close($ch);
}



function prepareXml($email,$firstName,$lastName,$groups) 
{
$userName="myUserName";
$password="myPassword!";
$xml='<?xml version="1.0" encoding="utf-8"?>
  <soap:Envelope 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Header>
		<SecHeader xmlns="http://www.inwise.com/schemas">
			<username>'.$userName.'</username>
			<pass>'.$password.'</pass>
		</SecHeader>
	</soap:Header>
	<soap:Body>
	  <Recipients_AddOrUpdate 
	    xmlns="http://www.inwise.com/schemas">
		<email>'.htmlspecialchars($email, ENT_QUOTES).'</email>
		<groups>';
$count=count($groups);
for($i=0;$i<$count;$i++)
{
$xml.=	'<anyType xsi:type="xsd:int">'.$groups[$i].'</anyType>';
}

$xml.='</groups>
		<fields>
		  <CustomFieldValue>
			<LocalName>field1</LocalName>
			<FieldValue xsi:type="xsd:string">'.htmlspecialchars($firstName, ENT_QUOTES).'</FieldValue>
		  </CustomFieldValue>
		  <CustomFieldValue>
			<LocalName>field2</LocalName>
			<FieldValue xsi:type="xsd:string">'.htmlspecialchars($lastName, ENT_QUOTES).'</FieldValue>
		  </CustomFieldValue>
		</fields>
	  </Recipients_AddOrUpdate>
	</soap:Body>
  </soap:Envelope>';
return $xml;
}

?>

<html>
<body>
	<form action="" method="post">
		First name: <input type="text" name="firstName"/><br/>
		Last name: <input type="text" name="lastName"/><br/>
		Email: <input type="text" name="email"/><br/>
		
		<input type="hidden" name="postback" value="true"/>
		<input type="submit" value="submit"/>
	</form>

</body>
</html>



Home  |  About us  |  Products  |  Service  |  Partners  |  Forum  |  Email Marketing Terms  |  Support  |  Contact us
Terms & Conditions  |  Privacy Policy  |  Anti Spam Policy  |  Site Map
© 2008 inwise LTD. All rights reserved.