Creating Triggered Send via SOAP API & PHP

<?php
require ('../../00 Includes/exacttarget_soap_client.php');

$wsdl = 'https://webservice.exacttarget.com/etframework.wsdl';
try
    {
    /* Create the Soap Client */
    $client = new ExactTargetSoapClient($wsdl, array(
        'trace' => 1
    ));
    echo "break1: start it off<br />";
    /* Set username and password here */
    $client->username = '<username>';
    $client->password = '<password>';
    echo "break2: authenticated<br />";
    /*% ExactTarget_TriggeredSendDefinition */
    $tsd = new ExactTarget_TriggeredSendDefinition();
    $tsd->CustomerKey = "Job Alert"; // unique identifier for the triggered send definition
    echo "break3: created triggered send object<br />";
    /*% ExactTarget_TriggeredSend */
    $ts = new ExactTarget_TriggeredSend();
    $ts->TriggeredSendDefinition = new SoapVar($tsd, SOAP_ENC_OBJECT, 'TriggeredSendDefinition', "http://exacttarget.com/wsdl/partnerAPI");
    echo "break4: created triggered send object<br />";

    // Associate a subscriber and attributes to the triggered send

    $ts->Subscribers = array();
    $subscriber = new ExactTarget_Subscriber();
    $subscriber->EmailAddress = "info@exacttarget.com"; // set the email address
    $subscriber->SubscriberKey = "info@exacttarget.com"; // optional, depending on account configuration
    /****************************************************************
    this commented out code is for use with an on your behalf send
    $subscriber->Owner = new ExactTarget_Owner();
    $subscriber->Owner->FromAddress = "FFFF@exacttarget.com";
    $subscriber->Owner->FromName = "FROM NAME";
    ****************************************************************/

    $ts->Subscribers[] = $subscriber; // add the subscriber to the send
    echo "break5: added subscriber info<br />";

    // create SoapVar object

    $object = new SoapVar($ts, SOAP_ENC_OBJECT, 'TriggeredSend', "http://exacttarget.com/wsdl/partnerAPI");
    echo "break6: created SoapVar object<br />";

    // create request object

    $request = new ExactTarget_CreateRequest();
    $request->Options = NULL;
    $request->Objects = array(
        $object
    );
    echo "break6: make request object<br />";

    // Create the triggered send definition

    $results = $client->Create($request);
    print_r($result);
    echo "break7: make request<br />";

    // Output the results

    var_dump($results);
    }

catch(SoapFault $e)
    {
    var_dump($e);
    }

echo "complete";
?>

Example

<?php
$emailaddress = $_POST['emailaddress'];

if (isset($_POST['emailaddress']))
    {
    require ('exacttarget_soap_client.php');

    $wsdl = 'https://webservice.s4.exacttarget.com/etframework.wsdl';
    echo "<pre>";
    try
        {
        /* Create the Soap Client */
        $client = new ExactTargetSoapClient($wsdl, array(
            'trace' => 1
        ));
        /* Set username and password here */
        $client->username = 'username';
        $client->password = 'password';

        // Create the subscriber object and define its attributes.

        $subscriber = new ExactTarget_Subscriber();

        // Set the properties to return

        $subscriber->EmailAddress = $emailaddress; // set the email address
        $subscriber->SubscriberKey = $emailaddress; // optional, depending on account configuration

        // Create the Triggered Send Definition and set it CustomerKey value to the external key of the TriggeredSendDefinition.

        $tsd = new ExactTarget_TriggeredSendDefinition();
        $tsd->CustomerKey = "12345"; // unique identifier for the triggered send definition

        // Create the TriggeredSend and set its TriggeredSendDefinition and Subscribers properties.

        $ts = new ExactTarget_TriggeredSend();
        $ts->TriggeredSendDefinition = new SoapVar($tsd, SOAP_ENC_OBJECT, 'TriggeredSendDefinition', "http://exacttarget.com/wsdl/partnerAPI");
        $ts->Subscribers = array();
        $ts->Subscribers = $subscriber;

        // Create the SoapVar object out of the TriggeredSend object.

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

        // Create the Request object and add the SoapVar object to it. (Options can be NULL.)

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

        // Execute the request.

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

        // Output the results

        var_dump($results);
        }

    catch(SoapFault $e)
        {
        var_dump($e);
        header(Location:
            http: //google.com’);
                }
?>