0

我在尝试创建新关键字时使用亚马逊广告 API 收到此错误:

“代码”:“422”

这是我的 PHP 代码:

curl_setopt($ch, CURLOPT_URL, $std_url . "/v2/sp/keywords"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);


$data_string = array(
    "campaignId" => "111111111111",
    "adGroupId" => "2222222222222",
    "state" => "enabled",
    "keywordText" => "YetAnotherKeyword",
    "matchType" => "broad",
    "bid" => "0.05");

curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);

$headers = array();
$headers[] = "Content-Type:application/json";
$headers[] = ("Authorization: Bearer " . $accesstoken);
$headers[] = ("Amazon-Advertising-API-ClientId: ". $client);
$headers[] = ("Amazon-Advertising-API-Scope: " . $API_Scope);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
echo $result;
4

1 回答 1

0

我有解决办法。数组需要修改如下:

$data_string = array(array(
    "campaignId" => "111111111111",
    "adGroupId" => "2222222222222",
    "state" => "enabled",
    "keywordText" => "YetAnotherKeyword",
    "matchType" => "broad",
    "bid" => "0.05"));
于 2021-11-25T20:43:04.150 回答