Marketo の API を使用してメールを送信しようとしています。私はこのチュートリアルに従っていますが、理解できないエラーが発生しています:{"requestId":"0000000000","success":false,"errors":[{"code":"711","message":"Invalid folder type for email"}]}
どういう意味ですか?フォルダを作成し、このフォルダ内にプログラムを作成し、このプログラム内にこの電子メールを作成しました。私が知っている限りでは、プログラムなしで電子メールを作成することはできないので、少し迷っています。
ありがとう
編集:私のリクエストを追加する:
私はphpでリクエストを作成しています:
<?php
$email = new CreateEmail();
$email->name = "MyEmailName";
$email->folder = new stdClass();
$email->folder->id = 3211;
$email->folder->type = "Folder";
$email->template = 0003;
$email->subject = "This email was created with an api call";
print_r($email->postData());
class CreateEmail{
private $host = "mydetails";
private $clientId = "mydetails";
private $clientSecret = "mydetails";
public $name;//name of new email, required - NOCEmai
public $folder;//json object with two members, id and type(Folder or Program), required
public $template;//id of parent template
public $description;//optional description of new
public $subject;//subject line of new email
public $fromName;//from name of new email
public $fromEmail;//from email of new email
public $replyEmail;//reply to address of new email
public $operational;//boolean operational status of email
public function postData(){
$url = $this->host . "/rest/asset/v1/emails.json?access_token=" . $this->getToken();
$ch = curl_init($url);
$requestBody = $this->bodyBuilder();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_getinfo($ch);
$response = curl_exec($ch);
return $response;
}
private function getToken(){
$ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',));
$response = json_decode(curl_exec($ch));
curl_close($ch);
$token = $response->access_token;
return $token;
}
private function bodyBuilder(){
$requestBody = "&name=" . $this->name . "&folder=" . json_encode($this->folder) . "&template=" . $this->template;
if (isset($this->description)){
$requestBody .= "&description=" . $this->description;
}
if (isset($this->subject)){
$requestBody .= "&subject=" . $this->subject;
}
if (isset($this->fromName)){
$requestBody .= "&fromName=" . $this->fromName;
}
if (isset($this->fromEmail)){
$requestBody .= "&fromEmail=" . $this->fromEmail;
}
if (isset($this->replyEmail)){
$requestBody .= "&replyEmail" . $this->replyEmail;
}
if (isset($this->operational)){
$requestBody .= "&operational=" . $this->operational;
}
return $requestBody;
}
}