使用API​​获取回复以获取广告系列

时间:2014-04-28 14:13:37

标签: php api getresponse getresponsestream

这是getresponse API的主要链接 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);
}

这是与PHP在同一页面上的HTML代码。

<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>

我在同一页面顶部的错误如下: array(0){} NULL

1 个答案:

答案 0 :(得分:1)

试用此代码:

# 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);