mautic - 如何将网站内容动态导入mautic
问题描述
我正在尝试使用 mautic 向用户发送时事通讯电子邮件,为了将其发送给一部分用户,我在频道 -> 电子邮件的构建器中复制并粘贴了网站的 html 代码。
但是我如何动态实现它,因为我有一些动态内容,例如:
<a href="https://www.website.com/?post_type=post&p=835383" target="_blank">
<img src="https://www.website.com/wp-content/uploads/2020/08/237228_cx__cy__cw__ch_-423x317.jpeg" width="100%" height="auto" style="display: block;" />
解决方案
我通过 file_get_contents 函数来做到这一点:
$html_string = file_get_contents('http://the url I want to import/');
$date = date('Y_m_d H:i');
$name=$_POST["newsletter"] . $date;
$subject=$_POST["subject"];
$segment=$_POST["segment"];
$result = httpPost("https://mautic url/api/emails/new",$html_string,$name,$subject,$segment);
function httpPost($url,$params,$name,$subject,$segment)
{
$header = array(
"Authorization: Basic encoded username and password"
);
$postData = array( 'name' => $name, 'subject' => $subject, 'customHtml' => $params ,'emailType'=>'list', 'lists'=> [$segment] );
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER, true);
curl_setopt($ch,CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, count($postData));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
$output=curl_exec($ch);
curl_close($ch);
return $output;
}
推荐阅读
- python - 给定由字典标识的组,形成具有共同值的键组(反向分组)
- python - numpy 1.18 生成的 SeedSequence 无法被 numpy 1.19 打开
- css - React CRA 暴露了 CSS 构建块中的绝对路径?
- python - 如何在 django 中获取名称而不是 id
- machine-learning - 在拆分数据之前使用单个 StandardScaler 是否正确?
- angular - 在 Ionic 5 / Angular 9 项目中添加外部 Javascipt 文件
- github - 为什么我不能通过 hub create 在 github 上创建 repo?
- python - 将垂直蒙版提取到单独的图像中
- emacs - 导航到特定 C++ 文件时,Emacs 非常慢
- wordpress - wordpress 分类网站可以根据广告类型显示/隐藏不同的 UI 元素吗