我正在使用 Campaign Monitor API 发送电子邮件。API 允许通过名为 create_from_template() 的方法创建模板化电子邮件。正如文档所说,我需要添加一些格式化参数。以下是活动监视器 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 发布请求时,我不断收到一条消息:
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
中,一切正常,但是当我添加一些参数时,它就不起作用了