Hello Stackoverflow:)
我正在为每天都有电子报纸的客户构建一个脚本。
电子报纸由第三方构建,当他们发布时,他们可以让系统访问我们选择的网址。
当他们的系统访问我们的URL时,我们不会将mailchimp自动电子邮件(带有电子纸的链接)发送给我们列表中的每个人。
所以我的问题是: Mailchimp中的自动付费功能可以为我们执行此操作,还是我们需要使用URL上的mailchimp API编写脚本以处理自动电子邮件列表?如果后者哪种方法应该在文档中查看?
不是在寻找一个完整的答案,而是指向正确的方向:)
Google没有帮助我解决以下问题:“在访问网址时将电子邮件发送到列表”,“在访问网址时将电子邮件广告系列发送到列表”这就是我现在求助于您的原因:)
提前致谢
答案 0 :(得分:1)
一般来说,您可以使用MailChimp的目标和自动化功能来完成这样的。但是,您正在处理需要包含在电子邮件中的动态生成的URL。到目前为止,我还没有将信息从“目标页面”传输到MailChimp - 除了目标脚本自动传输的数据。
所以我认为你正在寻找一份API工作。您需要使用“广告系列”方法(http://developer.mailchimp.com/documentation/mailchimp/reference/campaigns/)。
请注意,制作和发送广告系列是整个过程的两个不同步骤。您可以在同一页面的“操作”下找到“发送”方法。只需获取“创建”方法返回的ID,将其输入“发送”方法并观察魔法发生。
希望这有帮助!
答案 1 :(得分:1)
这就是它的全部荣耀!它'解决了我遇到的问题:)
<?php
/**
* Method for communicating with mailchimp API
*
* @param str $method Which url you need to access in the Mailchimp API
* @param str $type Which type of request (POST, GET etc)
* @param array $data Do you need to pass data along aswell in a multi dimensional array?
*
* @author Kenneth Johnsen <Johns3n@gmail.com>
* @return Server Header Response
*/
function request($method,$type, $data = false){
$apiKey = '<API KEY>';
$dataCenter = substr($apiKey,strpos($apiKey,'-')+1);
$url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0'.$method;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if($data){
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($data));
}
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// GET VARIABLES THAT MIGHT CHANGE DEPENDING ON E-PAPER SUPPLIER:
// -------------------------------------------------------------------------------------
$paper = 'Name of Company';
$replyTo = 'noreply@companyname.com';
$templateId = 65;
// CREATE CAMPAIGN AND RETURN THE ID SO WE CAN EDIT IT ASWELL:
// -------------------------------------------------------------------------------------
$campaign = array(
'type' => 'regular',
'recipients' => array(
'list_id' => '<LIST ID>'
),
'settings' => array(
'subject_line' => 'E-paper for '.$paper.' is now ready!',
'title' => $paper.' E-Paper Notification ('.date("d/m-Y").')',
'from_name' => $paper,
'reply_to' => $replyTo,
)
);
$createCampaign = request('/campaigns','POST',$campaign);
$createCampaign = json_decode($createCampaign);
// EDIT THE CAMPAIGN TO MATCH TEMPLATE ID:
// -------------------------------------------------------------------------------------
$editCampaign = array(
'template' => array(
'id' => $templateId
)
);
$updateCampaign = request('/campaigns/'.$createCampaign->id.'/content','PUT',$editCampaign);
// SCHEDULE THE CAMPAIGN FOR LAUNCH FROM NEAREST QUARTER MINUTE + ANOTHER 30 MINUTES:
// -------------------------------------------------------------------------------------
$time = time();
$time = round($time / (15 * 60)) * (15 * 60) + (30 * 60);
$time = date('i',$time);
$timeSchedule = date('Y-m-dTH:'.$time.':00+01:00');
$schedule = array(
'schedule_time' => $timeSchedule
);
$scheduleCampaign = request('/campaigns/'.$createCampaign->id.'/actions/schedule','POST',$schedule);
var_dump($scheduleCampaign);