Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('../../00 Includes/exacttarget_soap_client.php');
- $wsdl = 'https://webservice.s6.exacttarget.com/etframework.wsdl';
- try {
- /* Create the Soap Client */
- $client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
- /* Set username and password for the account here */
- $client->username = 'OMITTED_FOR_SECURITY_REASONS';
- $client->password = 'OMITTED_FOR_SECURITY_REASONS';
- /*% ExactTarget_Subscriber */
- $subscriber = new ExactTarget_Subscriber();
- $subscriber->SubscriberKey = "232424"; // optional depending on account configuration
- $subscriber->EmailAddress = "testy+2017-01-23-001@exacttarget.com"; // required
- /*% Create a profile attribute for the subscriber */
- $attribute1 = new ExactTarget_Attribute();
- $attribute1->Name = "FirstName";
- $attribute1->Value = "Sally";
- /*% Create a profile attribute for the subscriber */
- $attribute2 = new ExactTarget_Attribute();
- $attribute2->Name = "YearOfBirth";
- $attribute2->Value = "1976";
- /*% Create a profile attribute for the subscriber */
- $attribute3 = new ExactTarget_Attribute();
- $attribute3->Name = "Family ID";
- $attribute3->Value = "1234";
- /* Attach the profile attributes to the subcscriber */
- $subscriber->Attributes[] = $attribute1;
- $subscriber->Attributes[] = $attribute2;
- $subscriber->Attributes[] = $attribute3;
- /* Create the subscriber */
- $object = new SoapVar($subscriber, SOAP_ENC_OBJECT, 'Subscriber', "http://exacttarget.com/wsdl/partnerAPI");
- $request = new ExactTarget_CreateRequest();
- $request->Options = NULL;
- $request->Objects = array($object);
- $results = $client->Create($request);
- /* Output the results */
- var_dump($results);
- } catch (SoapFault $e) {
- var_dump($e);
- }
- ?>
- object(SoapFault)#9 (10) {
- ["message":protected]=>
- string(38) "An invalid security token was provided"
- ["string":"Exception":private]=>
- string(0) ""
- ["code":protected]=>
- int(0)
- ["file":protected]=>
- string(107) "/home/fbitn/public_html/PHP APIstarterKit-V1/01 Subscriber/01 Create Subscriber/exact_create_subscriber.php"
- ["line":protected]=>
- int(44)
- ["trace":"Exception":private]=>
- array(2) {
- [0]=>
- array(6) {
- ["file"]=>
- string(107) "/home/fbitn/public_html/PHP APIstarterKit-V1/01 Subscriber/01 Create Subscriber/exact_create_subscriber.php"
- ["line"]=>
- int(44)
- ["function"]=>
- string(6) "__call"
- ["class"]=>
- string(10) "SoapClient"
- ["type"]=>
- string(2) "->"
- ["args"]=>
- array(2) {
- [0]=>
- string(6) "Create"
- [1]=>
- array(1) {
- [0]=>
- object(ExactTarget_CreateRequest)#7 (2) {
- ["Options"]=>
- NULL
- ["Objects"]=>
- array(1) {
- [0]=>
- object(SoapVar)#6 (4) {
- ["enc_type"]=>
- int(301)
- ["enc_value"]=>
- object(ExactTarget_Subscriber)#2 (15) {
- ["EmailAddress"]=>
- string(38) "tmorgan+2017-01-23-001@exacttarget.com"
- ["Attributes"]=>
- array(3) {
- [0]=>
- object(ExactTarget_Attribute)#3 (3) {
- ["Name"]=>
- string(9) "FirstName"
- ["Value"]=>
- string(5) "Sally"
- ["Compression"]=>
- NULL
- }
- [1]=>
- object(ExactTarget_Attribute)#4 (3) {
- ["Name"]=>
- string(11) "YearOfBirth"
- ["Value"]=>
- string(4) "1976"
- ["Compression"]=>
- NULL
- }
- [2]=>
- object(ExactTarget_Attribute)#5 (3) {
- ["Name"]=>
- string(9) "Family ID"
- ["Value"]=>
- string(4) "1234"
- ["Compression"]=>
- NULL
- }
- }
- ["SubscriberKey"]=>
- string(6) "232424"
- ["UnsubscribedDate"]=>
- NULL
- ["Status"]=>
- NULL
- ["PartnerType"]=>
- NULL
- ["EmailTypePreference"]=>
- NULL
- ["Lists"]=>
- NULL
- ["GlobalUnsubscribeCategory"]=>
- NULL
- ["SubscriberTypeDefinition"]=>
- NULL
- ["Addresses"]=>
- NULL
- ["PrimarySMSAddress"]=>
- NULL
- ["PrimarySMSPublicationStatus"]=>
- NULL
- ["PrimaryEmailAddress"]=>
- NULL
- ["Locale"]=>
- NULL
- }
- ["enc_stype"]=>
- string(10) "Subscriber"
- ["enc_ns"]=>
- string(38) "http://exacttarget.com/wsdl/partnerAPI"
- }
- }
- }
- }
- }
- }
- [1]=>
- array(6) {
- ["file"]=>
- string(107) "/home/fbitn/public_html/PHP APIstarterKit-V1/01 Subscriber/01 Create Subscriber/exact_create_subscriber.php"
- ["line"]=>
- int(44)
- ["function"]=>
- string(6) "Create"
- ["class"]=>
- string(21) "ExactTargetSoapClient"
- ["type"]=>
- string(2) "->"
- ["args"]=>
- array(1) {
- [0]=>
- object(ExactTarget_CreateRequest)#7 (2) {
- ["Options"]=>
- NULL
- ["Objects"]=>
- array(1) {
- [0]=>
- object(SoapVar)#6 (4) {
- ["enc_type"]=>
- int(301)
- ["enc_value"]=>
- object(ExactTarget_Subscriber)#2 (15) {
- ["EmailAddress"]=>
- string(38) "tmorgan+2017-01-23-001@exacttarget.com"
- ["Attributes"]=>
- array(3) {
- [0]=>
- object(ExactTarget_Attribute)#3 (3) {
- ["Name"]=>
- string(9) "FirstName"
- ["Value"]=>
- string(5) "Sally"
- ["Compression"]=>
- NULL
- }
- [1]=>
- object(ExactTarget_Attribute)#4 (3) {
- ["Name"]=>
- string(11) "YearOfBirth"
- ["Value"]=>
- string(4) "1976"
- ["Compression"]=>
- NULL
- }
- [2]=>
- object(ExactTarget_Attribute)#5 (3) {
- ["Name"]=>
- string(9) "Family ID"
- ["Value"]=>
- string(4) "1234"
- ["Compression"]=>
- NULL
- }
- }
- ["SubscriberKey"]=>
- string(6) "232424"
- ["UnsubscribedDate"]=>
- NULL
- ["Status"]=>
- NULL
- ["PartnerType"]=>
- NULL
- ["EmailTypePreference"]=>
- NULL
- ["Lists"]=>
- NULL
- ["GlobalUnsubscribeCategory"]=>
- NULL
- ["SubscriberTypeDefinition"]=>
- NULL
- ["Addresses"]=>
- NULL
- ["PrimarySMSAddress"]=>
- NULL
- ["PrimarySMSPublicationStatus"]=>
- NULL
- ["PrimaryEmailAddress"]=>
- NULL
- ["Locale"]=>
- NULL
- }
- ["enc_stype"]=>
- string(10) "Subscriber"
- ["enc_ns"]=>
- string(38) "http://exacttarget.com/wsdl/partnerAPI"
- }
- }
- }
- }
- }
- }
- ["previous":"Exception":private]=>
- NULL
- ["faultstring"]=>
- string(38) "An invalid security token was provided"
- ["faultcode"]=>
- string(23) "q0:InvalidSecurityToken"
- ["faultactor"]=>
- string(50) "https://webservice.s6.exacttarget.com/Service.asmx"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement