Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

PHP API Triggered Send

General Tech Bugs & Fixes
Max. 2000 characters
Replies

usr_profile.png
Priyanka Chadda

User

( 6 months ago )

 

I am trying to create a triggered send using the API with PHP.

The soap call is registering, however, i don't believe the function is registering correctly. I have a Triggered Send Definition already set up in the account and a DE associated with it.

verification if statement is :

if (preg_match("/^([a-z]+[\w-]*\.?)+@([\w-]+\.)+[a-z]{2,4}$/i", $_POST['email'])) {

    date_default_timezone_set('UTC');
    $dateTime = new DateTime ();
    $setDateVal = date('n/j/Y',strtotime('now'));

    $email = $_POST['email'];
    $zip =  $_POST['zip'];

    include('exacttarget_soap_client.php');
    $wsdl = 'https://webservice.s4.exacttarget.com/etframework.wsdl';
        try {
            /* Create the Soap Client */
            $client = new ExactTargetSoapClient($wsdl, array('trace' => 1));

            /* Set username and password
             * 
             *  here */
            $client->username = '************';
            $client->password = '************';

            $subscriber = new ExactTarget_Subscriber();
            $subscriber->EmailAddress = $email;
            $subscriber->SubscriberKey = $email;

            // This section is needed if you are adding a subscriber to a Lock and Publish account using an enterprise API user

            $cl = new ExactTarget_APIObject();
            $cl->ID = **********;
            $cl->CustomerKey = '**********';
            $subscriber->Client = $cl;

            //% ExactTarget_Subscriber               
            $attribute1 = new ExactTarget_Attribute();
            $attribute1->Name = "POSTALCODE";
            $attribute1->Value = $zip;

            //% ExactTarget_Subscriber  
            $attribute3 = new ExactTarget_Attribute();
            $attribute3->Name = "DATE";
            $attribute3->Value = $setDateVal;

            //% ExactTarget_Subscriber 
            $attribute4 = new ExactTarget_Attribute();
            $attribute4->Name = "OPTIN";
            $attribute4->Value = "Y";

            $subscriber->Attributes = array($attribute1, $attribute2, $attribute3, $attribute4);

            // This is the section needed to define it as an "Upsert"
            $so = new ExactTarget_SaveOption();
            $so->PropertyName = "*";
            $so->SaveAction = ExactTarget_SaveAction::UpdateAdd;
            $soe = new SoapVar($so, SOAP_ENC_OBJECT, 'SaveOption', "http://exacttarget.com/wsdl/partnerAPI");
            $opts = new ExactTarget_UpdateOptions();
            $opts->SaveOptions = array($soe);

            $object = new SoapVar($subscriber, SOAP_ENC_OBJECT, 'Subscriber', "http://exacttarget.com/wsdl/partnerAPI");

            $request = new ExactTarget_CreateRequest();
            $request->Options = $opts;
            $request->Objects = array($object);


            $results = $client->Create($request);

            print_r($results);

        } catch (SoapFault $e) {

            print_r($e->faultstring);

        }
}

Am I using the correct code? Is there a TriggeredSend Shell available for PHP, and if so - where do i define subscriber/DE attributes?

usr_profile.png
Imran Malik

User

( 6 months ago )

Take a look at this example of TriggeredSend for the PHP Fuel SDK? This explains how you can set the subscribers while sending a triggered send.

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif