私は文書のこの部分に従っています:http://developers.marketo.com/rest-api/assets/tokens/と私はいつも次のエラーが表示されます:フィールドは空にすることはできません。Marketo REST APIアセットトークンは機能しますか?
誰かにそれを働かせてもらえますか?
public function create_token($folder_id,$name,$content,$folder_type = 'Program')
{
$folder_id = intval($folder_id);
$endpoint = 'rest/asset/v1/folder/'.$folder_id.'/tokens';
$body = new stdClass();
$body->folderType = $folder_type;
$body->name = $name;
$body->type = 'rich text';
$body->value = $content;
$body_encoded = json_encode($body);
echo $url = $this->url . $endpoint . ".json?access_token=" . self::$token;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body_encoded);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response);
}
Content-Typeヘッダの理由はMarketoからの提案だった:あなたがする必要はありません
object(stdClass)#1934 (4) {
["success"]=>
bool(false)
["warnings"]=>
array(0) {
}
["errors"]=>
array(4) {
[0]=>
object(stdClass)#1935 (2) {
["message"]=>
string(20) "name cannot be null."
["code"]=>
string(3) "701"
}
[1]=>
object(stdClass)#1936 (2) {
["message"]=>
string(20) "type cannot be null."
["code"]=>
string(3) "701"
}
[2]=>
object(stdClass)#1937 (2) {
["message"]=>
string(101) "Token type is either null, blank or invalid. Please refer to the documentation for valid token types."
["code"]=>
string(3) "701"
}
[3]=>
object(stdClass)#1938 (2) {
["message"]=>
string(21) "value cannot be null."
["code"]=>
string(3) "701"
}
}
["requestId"]=>
string(16) "11d1#15b49284636"
}