[英]How can i get campaign's web id when campaign is created using API in Mailchimp?
我使用mailchimp的API版本1.3在PHP中以编程方式创建Campaign。
我正在使用MCAPI
类方法campaignCreate()
创建广告系列。 广告系列创建成功,并返回响应的广告系列ID(字符串)。
但是我需要Web ID(广告系列ID的整数值),以便我可以使用它通过我网站上的链接打开该广告系列。
例如:可以说,我想用户重定向到这个链接- https://us8.admin.mailchimp.com/campaigns/show?id=941117和我需要的值id为941117时的新广告系列created.For现在使用mailchimp API创建新的广告系列时,我得到的字符串类似于6ae9ikag
请让我知道是否有人知道如何使用PHP中的Mailchimp API获取广告系列的Web ID(整数值)
谢谢
我找到了一个答案,所以想在这里分享。希望它可以帮助某人
使用MCAPI类的createCampaign()方法时,我以字符串形式获得广告系列ID。
您需要使用以下代码获取网络ID(广告系列ID的整数值)
$filters['campaign_id'] = $campaign_id; // string value of campaign id
$campaign = $api->campaigns($filters);
$web_id = $campaign['data'][0]['web_id'];
这对我有用。
谢谢
<?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);
?>
调用创建端点时,mailchimp将返回web_id。
$mcResponce = $mailchimp_api->campaigns->create(...);
$web_id = $mcResponce['web_id'];
请参阅文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.