Connecting to the API using PHP

This document contains conceptual and procedural information on connecting your development environment or other systems to the ExactTarget web service API via PHP.

Why Connect to the Web Service API using PHP

You can use the connection to the web service API to test your calls and perform various tasks, such as sending email and retrieving tracking information.

Prerequisites

You must follow the requirements below to connect to the web service API via PHP.

Required PHP Extensions

  • SOAP
  • mcrypt
  • openssl

Required PHP version

  • 5.2.3 and above

Required PHP Includes

  • soap-wsse.php
  • exacttarget_soap_client.php
  • xmlseclibs.php

Code

The sample code below demonstrates how to connect and interact with the web service API.

Authenticating with xmlseclibs

The xmlseclibs project provides a lightweight PHP library for XML security.

Prerequesite:

/* Set include directory for exacttarget PHP SOAP library files.
   The path to these files may already be set for the include_path 
   setting within the php.ini file */
$includeDir = realpath(dirname(__FILE__).'/../includes/');
$path = ini_get('include_path');
$path = $includeDir . PATH_SEPARATOR . $path;
ini_set('include_path', $path);

require('exacttarget_soap_client.php')

/* Set location of WSDL */
$wsdl = 'https://webservice.exacttarget.com/etframework.wsdl';

try	{
	/* Create the Soap Client */
	@$client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
	
	/* Set username and password here */
	$client->username = 'username';
	$client->password = 'password';
      
      /* Other Code Here */

}

The attached file contains all of the object classes contained in the ExactTarget WSDL. Use the objects to review and prepare your API calls.

 


Enter the digits 25615 backwards:
   
 

 

 

Tag page

Files 2

FileSizeDateAttached by 
exacttarget_soap_client.php
No description
53.68 kB11:51, 18 May 2010AdminActions
 soap-wsse.php
No description
10.66 kB19:58, 28 May 2010AdminActions
You must login to post a comment.