Advertisement
Guest User

ET TS

a guest
May 13th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.67 KB | None | 0 0
  1. <?php
  2. require('../../00 Includes/exacttarget_soap_client.php');
  3.  
  4. $wsdl = 'https://webservice.exacttarget.com/etframework.wsdl';
  5. echo "<pre>";
  6. try {
  7.         /* Create the Soap Client */
  8.         $client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
  9.        
  10.         echo "break1: start it off<br>";
  11.        
  12.         /* Set username and password here */
  13.         $client->username = 'MYUSERNAME';
  14.         $client->password = 'MYPASS';
  15.        
  16.         echo "break2: authenticated<br>";
  17.  
  18.         /*% ExactTarget_TriggeredSendDefinition */             
  19.         $tsd = new ExactTarget_TriggeredSendDefinition();
  20.         $tsd->CustomerKey = "Created via SOAP"; // unique identifier for the triggered send definition
  21.         echo "break3: created triggered send object<br>";
  22.  
  23.         /*% ExactTarget_TriggeredSend */               
  24.         $ts = new ExactTarget_TriggeredSend();
  25.         $ts->TriggeredSendDefinition = new SoapVar($tsd, SOAP_ENC_OBJECT, 'TriggeredSendDefinition', "http://exacttarget.com/wsdl/partnerAPI");
  26.         echo "break4: created triggered send object<br>";
  27.        
  28.         // Associate a subscriber and attributes to the triggered send
  29.         $ts->Subscribers = array();
  30.         $subscriber = new ExactTarget_Subscriber();
  31.         $subscriber->EmailAddress = "rec1@gmail.com"; // set the email address
  32.         $subscriber->SubscriberKey = "rec1@gmail.com"; // optional, depending on account configuration
  33.         /****************************************************************
  34.         ** this commented out code is for use with an on your behalf send
  35.         ****************************************************************/
  36.         $subscriber->Owner = new ExactTarget_Owner();
  37.         $subscriber->Owner->FromAddress = "xxx@domain.com";
  38.         $subscriber->Owner->FromName = "Tedd Fedd";
  39.        
  40.         $ts->Subscribers[] = $subscriber; // add the subscriber to the send
  41.         echo "break5: added subscriber info<br>";
  42.        
  43.         // create SoapVar object
  44.         $object = new SoapVar($ts, SOAP_ENC_OBJECT, 'TriggeredSend', "http://exacttarget.com/wsdl/partnerAPI");
  45.         echo "break6: created SoapVar object<br>";
  46.  
  47.         // create request object
  48.         $request = new ExactTarget_CreateRequest();
  49.         $request->Options = NULL;
  50.         $request->Objects = array($object);
  51.         echo "break6: make request object<br>";
  52.  
  53.         // Create the triggered send definition
  54.         $results = $client->Create($request);
  55.         print_r($result);
  56.         echo "break7: make request<br>";
  57.        
  58.         // Output the results
  59.         var_dump($results);
  60.  
  61. } catch (SoapFault $e) {
  62.     var_dump($e);
  63. }
  64.  
  65. // Output the request and response
  66. print "Request: \n".
  67. $client->__getLastRequestHeaders() ."\n";
  68. print "Request: \n".
  69. $client->__getLastRequest() ."\n";
  70. print "Response: \n".
  71. $client->__getLastResponseHeaders()."\n";
  72. print "Response: \n".
  73. $client->__getLastResponse()."\n";
  74.  
  75. echo "complete";
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement