我正在使用Campaign Monitor API发送电子邮件。 API允许通过名为create_from_template()的方法创建模板化电子邮件。作为the doc says,我需要添加一些格式化参数。以下是广告系列监视器create_from_template()方法实现的内容:
/**
* Creates a new campaign from a template based on the info provided.
* At least on of the ListIDs and Segments parameters must be provided
* @param string $client_id The client to create the campaign for
* @param array $campaign_info The campaign information to use during creation.
* This array should be of the form
* array(
* 'Subject' => string required The campaign subject
* 'Name' => string required The campaign name
* 'FromName' => string required The From name for the campaign
* 'FromEmail' => string required The From address for the campaign
* 'ReplyTo' => string required The Reply-To address for the campaign
* 'ListIDs' => array<string> optional An array of list ids to send the campaign to
* 'SegmentIDs' => array<string> optional An array of segment ids to send the campaign to
* 'TemplateID' => string required The ID of the template to use
* 'TemplateContent' => array required The content which will be used to fill the editable areas of the template
* )
* @access public
* @return CS_REST_Wrapper_Result A successful response will be the ID of the newly created campaign
*/
function create_from_template($client_id, $campaign_info)
{
return $this->post_request($this->_base_route . 'campaigns/' . $client_id . '/fromtemplate.json', $campaign_info);
}
因此我给了$ campaign_info参数
$list = array($list_id);
$data = array(
'Name' => $name_string,
'Subject' => $subject_string,
'FromName' => $some_name,
'FromEmail' => "contact@email.org",
'ReplyTo' => "contact@email.org",
'ListIDs' => $list_id,
'SegmentIDs' => array(),
'TemplateID' => 'a6dd1168417a6d7d7f94da70c3cafe15'
'TemplateContent' => array(
'Singlelines' => array('Content' => $a_string ,
'Href' => $a_href
),
'Multilines' => array('Content' => $content
),
'Images' => array('Content' => $some_url,
'Href' => $some_href,
)
)
);
但是当我向营销活动的监控服务器发送我的api post请求时,我继续发出消息:
object(CS_REST_Wrapper_Result)#32 (2) { ["response"]=> object(stdClass)#29 (2) { ["Code"]=> int(400) ["Message"]=> string(110) "Failed to deserialize your request. Please check the documentation and try again. Fields in error: campaign" } ["http_status_code"]=> int(400) }
有谁知道它可能来自哪里?
编辑:如果我传递这些参数
$template_content = array(
'Singlelines' => array(),
'Multilines' => array(),
'Images' => array(),
'Repeaters' => array()
);
然后在数组$data
'TemplateContent' => $template_content
中,一切正常,但是当我添加一些参数时,它将无法正常工作
答案 0 :(得分:3)
G'day user1611830,
根据sample in the github repo,每条单线,多线和图片都必须是array
的{{1}}。
最好为Repeater包含一个空的arrays
。
所以你可能正在寻找这样的东西(如果我缺少任何括号,请道歉,但只要你将另一条array
中的每条单线,多线和图像包裹起来,你应该是对的:< / p>
array()