[英]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.