如何在使用Mailchimp中的API创建广告系列时获取广告系列的网络ID?

时间:2015-07-02 05:10:56

标签: php api mailchimp

我正在使用mailchimp的API版本1.3以PHP编程方式创建Campaign。

我正在使用MCAPI类方法campaignCreate()来制作广告系列。广告系列已成功创建,并在响应中返回广告系列ID,即字符串。

但我需要网络ID(广告系列ID的整数值),以便我可以使用它来使用我网站上的链接打开该广告系列。

例如:假设我想将用户重定向到此链接 - https://us8.admin.mailchimp.com/campaigns/show?id=941117并且在创建新广告系列时我需要id值为941117.现在我在新广告系列时将其作为字符串像6ae9ikag是使用mailchimp API

创建的

如果有人知道如何使用PHP中的Mailchimp API获取广告系列网址ID(整数值),请告诉我

由于

3 个答案:

答案 0 :(得分:1)

我找到了一个答案,所以想在这里分享。希望它可以帮助某人

当使用MCAPI类的createCampaign()方法时,我将广告系列ID作为字符串。

您需要使用以下代码来获取网络ID(广告系列ID的整数值)

{{1}}

这对我有用。

由于

答案 1 :(得分:1)

<?php
/**
This Example shows how to create a basic campaign via the MCAPI class.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey

$api = new MCAPI($apikey);

$type = 'regular';

$opts['list_id'] = '5ceacbda08';
$opts['subject'] = 'Test Newsletter Mail';
$opts['from_email'] = 'guna@test.com'; 
$opts['from_name'] = 'guna';

$opts['tracking']=array('opens' => true, 'html_clicks' => true, 'text_clicks' => false);

$opts['authenticate'] = true;
$opts['analytics'] = array('google'=>'my_google_analytics_key');
$opts['title'] = 'Test Newsletter Title';

$content = array('html'=>'Hello html content message', 
    'text' => 'text text text *|UNSUB|*'
  );

$retval = $api->campaignCreate($type, $opts, $content);


if ($api->errorCode){
 echo "Unable to Create New Campaign!";
 echo "\n\tCode=".$api->errorCode;
 echo "\n\tMsg=".$api->errorMessage."\n";
} else {
 echo "New Campaign ID:".$retval."\n";
}

$retval = $api->campaignSendNow($retval);

?>

答案 2 :(得分:0)

当调用创建结束点时,mailchimp会返回web_id。

$mcResponce = $mailchimp_api->campaigns->create(...);
$web_id = $mcResponce['web_id'];

请参阅documentation