如何解决如何将网站内容动态导入到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,$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,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;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。