user3546239
user3546239

Reputation: 159

Getresponse using API to fetch campaign

This is the main link of the API for getresponse https://github.com/robertstaddon/GetResponse-PHP-Wrapper/blob/master/PHPwrapper/GetResponseAPI.class.php

if(isset($_POST['Generate'])) 
{   
    require_once dirname(__FILE__) . '/GetResponseAPI.class.php';
    $api = new GetResponse('APIKEY HERE');
    $campaigns   = (array)$api->getCampaigns();
    $campaignIDs = array_keys($campaigns);
    $campaign    = $api->getCampaignByID($campaignIDs[0]);
    var_dump($campaigns, $campaign);
}

This is the HTML code which is on the same page with the PHP.

<form method="post" action="">
<select name="Campaign" id="Campaign">
<?php foreach ( $campaign as $campaignID => $value ) { ?>
<option value="<?php echo $campaignID;?>"><?php echo $value;?></option>    
<?php } ?>
</select>
<input type="submit" value="Generate" name="Generate" id="Generate"/>
</form>

The error i'm getting at the top of the same page is the following : array(0) { } NULL

Upvotes: 0

Views: 2186

Answers (1)

Weblizar
Weblizar

Reputation: 11

Try This Code:

# DOWNLOAD FILE FROM - http://jsonrpcphp.org/?page=download&lang=en
require_once 'jsonRPCClient.php';

# your API key is available at
# https://app.getresponse.com/my_api_key.html
$api_key = 'YOUR_API_KEY_HERE';

# API 2.x URL
$api_url = 'http://api2.getresponse.com';

# initialize JSON-RPC client
$client = new jsonRPCClient($api_url);

# get campaigns list
$campaigns = $client->get_campaigns(
    $api_key
);

# All Your Campaigns List
 print_r($campaigns);

Upvotes: 1

Related Questions