Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.19 KB | None | 0 0
  1. <?php
  2. require('../../00 Includes/exacttarget_soap_client.php');
  3. $wsdl = 'https://webservice.s6.exacttarget.com/etframework.wsdl';
  4.  
  5. try {
  6. /* Create the Soap Client */
  7. $client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
  8. /* Set username and password for the account here */
  9. $client->username = 'OMITTED_FOR_SECURITY_REASONS';
  10. $client->password = 'OMITTED_FOR_SECURITY_REASONS';
  11.  
  12. /*% ExactTarget_Subscriber */
  13. $subscriber = new ExactTarget_Subscriber();
  14. $subscriber->SubscriberKey = "232424"; // optional depending on account configuration
  15. $subscriber->EmailAddress = "testy+2017-01-23-001@exacttarget.com"; // required
  16.  
  17. /*% Create a profile attribute for the subscriber */
  18. $attribute1 = new ExactTarget_Attribute();
  19. $attribute1->Name = "FirstName";
  20. $attribute1->Value = "Sally";
  21.  
  22. /*% Create a profile attribute for the subscriber */
  23. $attribute2 = new ExactTarget_Attribute();
  24. $attribute2->Name = "YearOfBirth";
  25. $attribute2->Value = "1976";
  26.  
  27. /*% Create a profile attribute for the subscriber */
  28. $attribute3 = new ExactTarget_Attribute();
  29. $attribute3->Name = "Family ID";
  30. $attribute3->Value = "1234";
  31.  
  32. /* Attach the profile attributes to the subcscriber */
  33. $subscriber->Attributes[] = $attribute1;
  34. $subscriber->Attributes[] = $attribute2;
  35. $subscriber->Attributes[] = $attribute3;
  36.  
  37. /* Create the subscriber */
  38. $object = new SoapVar($subscriber, SOAP_ENC_OBJECT, 'Subscriber', "http://exacttarget.com/wsdl/partnerAPI");
  39. $request = new ExactTarget_CreateRequest();
  40. $request->Options = NULL;
  41. $request->Objects = array($object);
  42. $results = $client->Create($request);
  43.  
  44. /* Output the results */
  45. var_dump($results);
  46.  
  47. } catch (SoapFault $e) {
  48. var_dump($e);
  49. }
  50. ?>
  51.  
  52. object(SoapFault)#9 (10) {
  53. ["message":protected]=>
  54. string(38) "An invalid security token was provided"
  55. ["string":"Exception":private]=>
  56. string(0) ""
  57. ["code":protected]=>
  58. int(0)
  59. ["file":protected]=>
  60. string(107) "/home/fbitn/public_html/PHP APIstarterKit-V1/01 Subscriber/01 Create Subscriber/exact_create_subscriber.php"
  61. ["line":protected]=>
  62. int(44)
  63. ["trace":"Exception":private]=>
  64. array(2) {
  65. [0]=>
  66. array(6) {
  67. ["file"]=>
  68. string(107) "/home/fbitn/public_html/PHP APIstarterKit-V1/01 Subscriber/01 Create Subscriber/exact_create_subscriber.php"
  69. ["line"]=>
  70. int(44)
  71. ["function"]=>
  72. string(6) "__call"
  73. ["class"]=>
  74. string(10) "SoapClient"
  75. ["type"]=>
  76. string(2) "->"
  77. ["args"]=>
  78. array(2) {
  79. [0]=>
  80. string(6) "Create"
  81. [1]=>
  82. array(1) {
  83. [0]=>
  84. object(ExactTarget_CreateRequest)#7 (2) {
  85. ["Options"]=>
  86. NULL
  87. ["Objects"]=>
  88. array(1) {
  89. [0]=>
  90. object(SoapVar)#6 (4) {
  91. ["enc_type"]=>
  92. int(301)
  93. ["enc_value"]=>
  94. object(ExactTarget_Subscriber)#2 (15) {
  95. ["EmailAddress"]=>
  96. string(38) "tmorgan+2017-01-23-001@exacttarget.com"
  97. ["Attributes"]=>
  98. array(3) {
  99. [0]=>
  100. object(ExactTarget_Attribute)#3 (3) {
  101. ["Name"]=>
  102. string(9) "FirstName"
  103. ["Value"]=>
  104. string(5) "Sally"
  105. ["Compression"]=>
  106. NULL
  107. }
  108. [1]=>
  109. object(ExactTarget_Attribute)#4 (3) {
  110. ["Name"]=>
  111. string(11) "YearOfBirth"
  112. ["Value"]=>
  113. string(4) "1976"
  114. ["Compression"]=>
  115. NULL
  116. }
  117. [2]=>
  118. object(ExactTarget_Attribute)#5 (3) {
  119. ["Name"]=>
  120. string(9) "Family ID"
  121. ["Value"]=>
  122. string(4) "1234"
  123. ["Compression"]=>
  124. NULL
  125. }
  126. }
  127. ["SubscriberKey"]=>
  128. string(6) "232424"
  129. ["UnsubscribedDate"]=>
  130. NULL
  131. ["Status"]=>
  132. NULL
  133. ["PartnerType"]=>
  134. NULL
  135. ["EmailTypePreference"]=>
  136. NULL
  137. ["Lists"]=>
  138. NULL
  139. ["GlobalUnsubscribeCategory"]=>
  140. NULL
  141. ["SubscriberTypeDefinition"]=>
  142. NULL
  143. ["Addresses"]=>
  144. NULL
  145. ["PrimarySMSAddress"]=>
  146. NULL
  147. ["PrimarySMSPublicationStatus"]=>
  148. NULL
  149. ["PrimaryEmailAddress"]=>
  150. NULL
  151. ["Locale"]=>
  152. NULL
  153. }
  154. ["enc_stype"]=>
  155. string(10) "Subscriber"
  156. ["enc_ns"]=>
  157. string(38) "http://exacttarget.com/wsdl/partnerAPI"
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. [1]=>
  165. array(6) {
  166. ["file"]=>
  167. string(107) "/home/fbitn/public_html/PHP APIstarterKit-V1/01 Subscriber/01 Create Subscriber/exact_create_subscriber.php"
  168. ["line"]=>
  169. int(44)
  170. ["function"]=>
  171. string(6) "Create"
  172. ["class"]=>
  173. string(21) "ExactTargetSoapClient"
  174. ["type"]=>
  175. string(2) "->"
  176. ["args"]=>
  177. array(1) {
  178. [0]=>
  179. object(ExactTarget_CreateRequest)#7 (2) {
  180. ["Options"]=>
  181. NULL
  182. ["Objects"]=>
  183. array(1) {
  184. [0]=>
  185. object(SoapVar)#6 (4) {
  186. ["enc_type"]=>
  187. int(301)
  188. ["enc_value"]=>
  189. object(ExactTarget_Subscriber)#2 (15) {
  190. ["EmailAddress"]=>
  191. string(38) "tmorgan+2017-01-23-001@exacttarget.com"
  192. ["Attributes"]=>
  193. array(3) {
  194. [0]=>
  195. object(ExactTarget_Attribute)#3 (3) {
  196. ["Name"]=>
  197. string(9) "FirstName"
  198. ["Value"]=>
  199. string(5) "Sally"
  200. ["Compression"]=>
  201. NULL
  202. }
  203. [1]=>
  204. object(ExactTarget_Attribute)#4 (3) {
  205. ["Name"]=>
  206. string(11) "YearOfBirth"
  207. ["Value"]=>
  208. string(4) "1976"
  209. ["Compression"]=>
  210. NULL
  211. }
  212. [2]=>
  213. object(ExactTarget_Attribute)#5 (3) {
  214. ["Name"]=>
  215. string(9) "Family ID"
  216. ["Value"]=>
  217. string(4) "1234"
  218. ["Compression"]=>
  219. NULL
  220. }
  221. }
  222. ["SubscriberKey"]=>
  223. string(6) "232424"
  224. ["UnsubscribedDate"]=>
  225. NULL
  226. ["Status"]=>
  227. NULL
  228. ["PartnerType"]=>
  229. NULL
  230. ["EmailTypePreference"]=>
  231. NULL
  232. ["Lists"]=>
  233. NULL
  234. ["GlobalUnsubscribeCategory"]=>
  235. NULL
  236. ["SubscriberTypeDefinition"]=>
  237. NULL
  238. ["Addresses"]=>
  239. NULL
  240. ["PrimarySMSAddress"]=>
  241. NULL
  242. ["PrimarySMSPublicationStatus"]=>
  243. NULL
  244. ["PrimaryEmailAddress"]=>
  245. NULL
  246. ["Locale"]=>
  247. NULL
  248. }
  249. ["enc_stype"]=>
  250. string(10) "Subscriber"
  251. ["enc_ns"]=>
  252. string(38) "http://exacttarget.com/wsdl/partnerAPI"
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. ["previous":"Exception":private]=>
  260. NULL
  261. ["faultstring"]=>
  262. string(38) "An invalid security token was provided"
  263. ["faultcode"]=>
  264. string(23) "q0:InvalidSecurityToken"
  265. ["faultactor"]=>
  266. string(50) "https://webservice.s6.exacttarget.com/Service.asmx"
  267. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement