We recently added an open source PHP Rest Client to help make requests to Eloqua's API a little easier. In today's post, we'll show you how to create and manage Landing Pages using the client.

Let's start by including and instantiating a new instance of the client :

 

// include the Rest client
include_once('lib/eloquaRequest.php');
$client = new EloquaRequest('site', 'user', 'password', 'https://secure.eloqua.com/API/REST/1.0/');

 

Next, let's define a class to represent a Landing Page record :

 

class LandingPage
    {
        public $createdAt;
        public $createdBy;
        public $htmlContent;
        public $id;
        public $name;
        public $updatedAt;
        public $updatedBy;
    }

 

Note that the HTML Content property is a complex type, represented by the following class :

 

class RawHtmlContent
    {
        public $type;
        public $html;
    }

 

Search Landing Pages

The following sample invokes a GET request to search for Landing Pages matching "Demand*" :

 

$list = $client->get('assets/landingPages?search=Demand*&count=50&page=1&depth=complete');

 

Create a Landing Page

The following sample creates a new Landing Page object and invokes an HTTP POST request to create the record :

 

$lp = new LandingPage();
$lp->name = 'sample landing page';
$htmlContent = new RawHtmlContent();
$htmlContent->html = '<html><head></head><body>sample content</body></html>';
$lp->htmlContent = $htmlContent;
$response = $client->post('assets/landingPage', $lp);

 

Update a Landing Page

The following sample invokes an HTTP PUT request to update an existing Landing Page.

 

$updatedLP = new LandingPage();
$updatedLP->id = $response->id;
$updatedLP->name = 'updated sample name';
$updatedLP = $client->put('/assets/landingPage/' . $updatedLP->id, $updatedLP);

 

Delete a Landing Page

The following sample invokes an HTTP DELETE request to delete an existing Landing Page

 

$client->delete('/assets/landingPage/' . $updatedLP->id);

 

We hope that you find this helpful.

 

Thanks,

Fred