GODADDY DOMAIN API for Purchase is Not working.
It was working For two years and suddenly started throwing the following error.
"POST https://api.godaddy.com/v1/domains/purchase` resulted in a `415 Unsupported Media Type` response:
{"code":415,"message":"unsupported media type \"application/x-www-form-urlencoded\", only [application/json application/xml text/xml] are allowed"}"
Only on Purchase route, rest all routes are working fine ex: domain, available
WHM OS Version : CENTOS 6.10 KVM [server] v78.0.13
Language: PHP 7.0
client to hit API Used: Guzzle Client
Here is my Guzzle code:-
尝试{ $ 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'], “传真” =>“”, “ addressMailing” => [ “ address1” => $ row ['user_address1'], “ address2” =>“, “ city” => $ row ['user_city'], “ state” => $ row ['user_state'], “ postalCode” => $ row ['user_postal_code'], “国家/地区” => $ 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", 'Accept' => 'application/json', 'X-Shopper-Id' => '145657150' ]; $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 () ); }
答案 0 :(得分:0)
将“接受”更改为“内容类型”。 使用此代码。
<Login />