godaddy-api - GODADDY DOMAIN API for Purchase 收到 400 Bad Request 客户端错误
问题描述
[03-Jul-2019 09:27:28 UTC] 打印错误:客户端错误:POST https://api.godaddy.com/v1/domains/purchase
导致400 Bad Request
响应:{"code":400,"message":"parsing body body from \"\" failed, because invalid character ' d' 寻找值的开始"}
仅在购买路线上,其余所有路线都可以正常工作,例如:域,可用
WHM OS 版本:CENTOS 6.10 KVM [server] v78.0.13 语言:PHP 7.0 客户端使用 API:Guzzle 客户端
这是我的 Guzzle 代码:-
try { $contactRegistrant = [ "nameFirst" => $row ['user_first_name'], "nameMiddle" => $row ['user_middle_name'], "nameLast" => $row ['user_last_name'], "organization" => $row ['user_organization'], "jobTitle" => $row ['user_job'], "email" => $row ['user_email'], "phone" => $row ['user_phone'], "fax" => "", "addressMailing" => [ "address1" => $row ['user_address1'], "address2" => '', "city" => $row ['user_city'], "state" => $row ['user_state'], "postalCode" => $row ['user_postal_code'], "country" => $row ['user_country'] ] ];
$form_params = [
"domain" => $domain,
"consent" => [
"agreementKeys" => [
$agreement->key
],
"agreedBy" => $agreedBy,
"agreedAt" => "2017-08-17T05:46:12Z"
],
// "period"=>1,
"nameServers" => [
$nameServer1,
$nameServer2
],
// "renewAuto"=> 'true',
// "privacy"=> 'true',
"contactRegistrant" => $contactRegistrant,
"contactAdmin" => $contactRegistrant,
"contactTech" => $contactRegistrant,
"contactBilling" => $contactRegistrant
];
$headers = [
'Authorization' => "sso-key $AKEY:$SKEY",
'Content-Type' => 'application/json',
'X-Shopper-Id' => '?????????'
];
$url = 'v1/domains/purchase';
//https://developer.godaddy.com/doc/endpoint/domains#/v1/purchase
// Hitting the GODADDY REST API Using Guzzel CLIENT
$client = new GuzzleHttp\Client ( [
'base_uri' => 'https://api.godaddy.com',
'verify' => true
] );
$responce = $client->post ( $url, [
'headers' => $headers,
'form_params' => $form_params
] );
error_log ( 'godaddy response:' . json_encode ( $responce ) );
return $responce->getBody ();
} catch ( Exception $e ) {
error_log ( 'error printed :' . $e->getMessage () );
}
解决方案
推荐阅读
- python - 如何设计 Python 代码以方便第三方的插件/定制
- java - 为什么这个 GUI 应用程序不显示图像?
- excel - 具有相同结果的第二、第三最佳值(VLOOKUP、MATCH...)
- javascript - 使用 CodeMirror 简单模式“覆盖”多个标记/规则/样式的方法?
- javascript - 使用 react-select V2 进行正确的组件样式组合
- 3d - 检测 3D 网格上的水平和垂直表面
- spring-boot - 无法将“服务器”下的属性绑定到 org.springframework.boot.autoconfigure.web.ServerProperties:
- javascript - 在 Node.js ES6 中使用 eval 创建变量失败
- swift4.1 - 如何以编程方式浏览按钮
- docker - 如何从包含多个 docker 图像的 tar 球中加载单个 docker 图像