|
|
Documentation Wiki > Developer Documentation > Web Service Guide > Getting Started: Developers and the ExactTarget API > Connecting to the API using PHP
Connecting to the API using PHPFrom $1Table of contents(Click the banner to go to the related Docs.Code.ExactTarget.com page.) 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 PHPYou 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. PrerequisitesYou must follow the requirements below to connect to the web service API via PHP. Required PHP Extensions
Required PHP version
Required PHP Includes
CodeThe sample code below demonstrates how to connect and interact with the web service API. Creating a New exact_target_client.php FileOnce you have the required PHP includes installed, enter the following commands in your command line: (DriveLetter):\Apps\ php5> php.exe exact_soap_client_creator.php https://webservice.exacttarget.com/etframework.wsdl > exacttarget_soap_client.php Authenticating with xmlseclibsThe 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. While the PHP SoapClient class allows for referencing a live version of the WSDL (which it uses when it builds the requests), you may experience better performance and reliability by saving a local copy of the WSDL at the time you develop your integration. That copy of the WSDL will be included in your project. For example, reference etframework.wsdl instead of the full address. You can use the following code sample to verify your connection to the ExactTarget API: $param = new ExactTarget_VersionInfoRequestMsg(); $param->IncludeVersionHistory = True; $results = $client->VersionInfo($param); var_dump($results); This page was last updated by Ryan Williams on Fri, 06 Jan 2012 21:26:25 GMT. If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:
Tags: (Edit tags)
|
|
Powered by MindTouch 2010 |