我正在尝试通过selly.gg
API创建产品并收到以下错误:
400 {“消息”:“验证失败”,“错误”:[“主题未包含在列表中”]}
我已经尝试过的方法:100次编辑我的json,从文档等中精确地复制粘贴它,尝试了许多连接方法,已经阅读了大量资源以自己发现错误...但是什么都没有
我当前的代码:
<?php
$URL='https://selly.gg/api/v2/products';
$data = [
'title' => 'test title',
'description'=> 'test description',
'stock' => '1',
'private' => 'false',
"unlisted" => 'true',
"seller_note" => 'test seller note',
'price' => '9.99',
'currency' => 'USD',
'gateways' => ['paypal'],
'product_type' => '2',
'info' => 'FirstKey, SecondKey, ThirdKey'
];
$data_json = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Authorization: Basic " . base64_encode("mega4642179@gmail.com:3pnAUztziYgZDaAbNjYSuWSeNhtCjcfET8XLFxe8FH2W2kaoBg"),
'Content-Type: application/json',
'Content-Length: ' . strlen($data_json)
));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_USERAGENT, "SellyDirection - selly.loc");
$result = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Display errors
echo $status_code;
echo $result;
curl_close ($ch);
?>