Adding asubscriber in openemm 2012 beta3 in php via SOAP

Use this forum for all questions related to the source code of OpenEMM

Moderator: moderator

lerra
Posts: 4
Joined: Sun Dec 23, 2012 4:14 pm

Adding asubscriber in openemm 2012 beta3 in php via SOAP

Post by lerra »

Hi,

I have now tried allot to get the api working to add a email into openemm,

What ever I try it seams like the values is sent wrong,

This is what I use together with the WS example file,

try {
$client = new WsseSoapClient( $wsdlURL, $username, $password);
} catch (SOAPFault $f) { print $f->faultstring; }
$subscriber=array('email'=>'test@hotmail.com','mailtype'=>0,'gender'=>0);
$params = array(
'in2' => 'true',
'in3' => 'email',
'in4' => 'false',
'parameters'=>$subscriber);
# 'in5' => array_keys($subscriber),
# 'in6' => array_values($subscriber));

/* 'doubleCheck' => 'true',
'keyColumn' => 'email',
'overwrite' => 'false',
'paramNames' => array(1 => 'gender', 2 => 'mailtype', 3 => 'email' ),
'paramValues' => array(1 => '0', 2 => '0', 3 => 'test@hotmail.com'));
*/
try {
$result = $client->__soapCall("addSubscriber",$params);
} catch (SOAPFault $f) { echo "\n";print $f->faultstring; echo "\n";}

The comment out parts is what I have been trying, I have also tried in other ways but every combination returns "mailtype is required",

Any input?
shi
Posts: 6
Joined: Thu Jan 03, 2013 3:36 pm

Re: Adding asubscriber in openemm 2012 beta3 in php via SOAP

Post by shi »

I have the same problem with OpenEMM 2013 RC3.

I have also tried to generate a request like explained in the webservice api documentation but I always get:
Uncaught SoapFault exception: [SOAP-ENV:Client] mailtype is required in ...

This is how I tryed to add a subscriber:

Code: Select all

$params = array();
$params["doubleCheck"] = "true";
$params["keyColumn"] = "email";
$params["overwrite"] = "true";
$params["parameters"] = array(	array("key" => "mailtype", "value" => "0"),
								array("key" => "email", "value" => "test@example.com"),
								array("key" => "gender", "value" => "0"),
							);
$sub_id = $this->emm->addSubscriber($params);
It also generates a XML-Request like in the documentation:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://agnitas.org/ws/schemas">
<SOAP-ENV:Header>
	<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
		<wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:Username>remote_admin</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest">ci1WgEQw4JEKOl+CqObZuGE+LXg=</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">YmI2MmM4NjIzNGNhODdhOGViNWQ=</wsse:Nonce><wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">2013-01-03T14:14:20Z</wsu:Created></wsse:UsernameToken>
	</wsse:Security>
	</SOAP-ENV:Header><SOAP-ENV:Body>
		<ns1:AddSubscriberRequest>
			<ns1:doubleCheck>true</ns1:doubleCheck>
			<ns1:keyColumn>email</ns1:keyColumn>
			<ns1:overwrite>true</ns1:overwrite>
		
			<ns1:parameters>
				<ns1:item>
					<ns1:key>mailtype</ns1:key>
					<ns1:value>0</ns1:value>
				</ns1:item>
				
				<ns1:item>
					<ns1:key>email</ns1:key>
					<ns1:value>shi-89@gmx.net</ns1:value>
				</ns1:item>
				
				<ns1:item>
					<ns1:key>gender</ns1:key>
					<ns1:value>0</ns1:value>
				</ns1:item>
			</ns1:parameters>
			
		</ns1:AddSubscriberRequest>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Help us, please :(
mdoerschmidt
Posts: 25
Joined: Fri Jan 04, 2013 8:55 am

Re: Adding asubscriber in openemm 2012 beta3 in php via SOAP

Post by mdoerschmidt »

PHP does not add type information to the SOAP request. In most cases, this is no problem. For any data, that has type "Map", type information is required for keys and values.
If type information is required, you have to add it manually.

Try this one:

Code: Select all

$profile = array(
  array( 
    "key" => new SoapVar( "email", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"),
    "value" => new SoapVar( "test@example.com", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema")
  ),
  array(
    "key" =>  new SoapVar( "mailtype", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"),
    "value" => new SoapVar( 0, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema")
  ),
  array( 
    "key" => new SoapVar( "gender", XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema"),
    "value" => new SoapVar( 0, XSD_STRING, "string", "http://www.w3.org/2001/XMLSchema")
  )
);

$data = array(
  "doubleCheck" => true,
  "overwrite" => false,
  "parameters" => $profile,
  "keyColumn" => "email"
);

As you can see, 

var_dump( $client->AddSubscriber( $data));


Best regards,

Markus
shi
Posts: 6
Joined: Thu Jan 03, 2013 3:36 pm

Re: Adding asubscriber in openemm 2012 beta3 in php via SOAP

Post by shi »

Ok this worked! Thank you very much!
Post Reply