Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.56 KB | None | 0 0
  1. $first_name = $last_name = '';
  2. $name_details = explode(" ", $Name);
  3. if (isset($name_details[0])) {
  4. $first_name = $name_details[0];
  5. }
  6. if (isset($name_details[1])) {
  7. $$last_name = $name_details[1];
  8. }
  9. /* Create the Soap Client */
  10. @$client = new ExactTargetSoapClient($this->wsdl, array('trace'=>1));
  11.  
  12. /* Set username and password here */
  13. $client->username = SOAP_USER;
  14. $client->password = SOAP_PASSWORD;
  15.  
  16. $ts = new ExactTarget_TriggeredSend();
  17. $tsd = new ExactTarget_TriggeredSendDefinition();
  18. $tsd->CustomerKey = "e-Gift";
  19.  
  20. $FirstName = new ExactTarget_Attribute();
  21. $FirstName->Name = "First_name";
  22. $FirstName->Value = $first_name;
  23.  
  24. $LastName = new ExactTarget_Attribute();
  25. $LastName->Name = "Last_name";
  26. $LastName->Value = $last_name;
  27.  
  28. $GiftMessage = new ExactTarget_Attribute();
  29. $GiftMessage->Name = "GiftPersonalMessage";
  30. $GiftMessage->Value = $Message;
  31.  
  32. $sub = new ExactTarget_Subscriber();
  33. $sub->EmailAddress = $Email;
  34. $sub->SubscriberKey = $Email;
  35.  
  36. //$sub->Attributes = array($UserName);
  37. $tsd->Attributes = array($FirstName, $LastName,$GiftMessage);
  38.  
  39. $ts->Subscribers = array();
  40. $ts->Subscribers = $sub;
  41. $ts->TriggeredSendDefinition = $tsd;
  42.  
  43. $object = new SoapVar($ts, SOAP_ENC_OBJECT, 'TriggeredSend', "http://exacttarget.com/wsdl/partnerAPI");
  44.  
  45. echo '<pre>';
  46. //print_r($object);
  47. echo '</pre>';
  48. echo "<br><br>";
  49. $request = new ExactTarget_CreateRequest();
  50. $request->Options = null;
  51. $request->Objects = array($object);
  52.  
  53. $results = $client->Create($request);
  54.  
  55. $first_name = $last_name = '';
  56. $name_details = explode(" ", $Name);
  57. if (isset($name_details[0])) {
  58. $first_name = $name_details[0];
  59. }
  60. if (isset($name_details[1])) {
  61. $last_name = $name_details[1];
  62. }
  63. /* Create the Soap Client */
  64. $client = new ExactTargetSoapClient($this->wsdl, array('trace'=>1));
  65.  
  66. /* Set username and password here */
  67. $client->username = SOAP_USER;
  68. $client->password = SOAP_PASSWORD;
  69.  
  70. $schr = new ExactTarget_ScheduleRequestMsg();
  71. $schr->Action = "start";
  72. $schr->Interactions = array();
  73.  
  74. $DateTimeString = date(DATE_ATOM, strtotime($datetime));
  75. $SendTime = new DateTime($DateTimeString);
  76. $SendTime->setTimezone(new DateTimeZone('UTC'));
  77.  
  78. $etr = new ExactTarget_DailyRecurrence();
  79. $etr->DailyRecurrencePatternType = ExactTarget_DailyRecurrencePatternTypeEnum::Interval;
  80. $etr->DayInterval = 1;
  81.  
  82. $senddeflist = new ExactTarget_SendDefinitionList();
  83. $senddeflist->DataSourceTypeID = "List";
  84.  
  85. $emailobj = new ExactTarget_Email();
  86. $emailobj->ID = $emailId;
  87.  
  88. $esd = new ExactTarget_EmailSendDefinition();
  89. $esd->SendDefinitionList = $senddeflist;
  90. $esd->Email = $emailobj;
  91. $esd->First_name = $first_name;
  92. $esd->Last_name = $last_name;
  93. //$esd->SendClassification = $sendclass;
  94. $esd->CustomerKey = 'e-Gift';
  95.  
  96. /*$sub = new ExactTarget_Subscriber();
  97. $sub->EmailAddress = $Email;
  98. $sub->SubscriberKey = $Email;
  99.  
  100. $esd->Subscribers = array();
  101. $esd->Subscribers = $sub;
  102. $esd->TriggeredSendDefinition = $tsd;*/
  103.  
  104. $sd = new ExactTarget_ScheduleDefinition();
  105. $sd->RecurrenceType = ExactTarget_RecurrenceTypeEnum::Daily;
  106. $sd->RecurrenceRangeType = ExactTarget_RecurrenceRangeTypeEnum::EndAfter;
  107. $sd->StartDateTime = $SendTime->format("c");
  108. $sd->Occurrences = 1;
  109. $sd->Recurrence = new SoapVar($etr, SOAP_ENC_OBJECT, 'DailyRecurrence', 'http://exacttarget.com/wsdl/partnerAPI');
  110.  
  111. $schr->Schedule = $sd;
  112.  
  113.  
  114. //$sendclass = new ExactTarget_SendClassification();
  115. //$sendclass->CustomerKey = $customerKey;
  116.  
  117. $schr->Interactions[] = new SoapVar($esd, SOAP_ENC_OBJECT, 'EmailSendDefinition', 'http://exacttarget.com/wsdl/partnerAPI');
  118. $schr->Options = null;
  119.  
  120.  
  121. echo '<pre>';
  122. //print_r($schr);
  123. echo '</pre>';
  124.  
  125. $results = $client->Schedule($schr);
  126.  
  127. echo '<pre>';
  128. //print_r($results);
  129. echo '</pre>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement