use Guzzle wit name.com api
that is the Curl example
Код: Выделить всё
curl -u 'username:token' 'https://api.dev.name.com/v4/domains:checkAvailability' -X POST -H 'Content-Type: application/json' --data '{"domainNames":["example.org"]}' Код: Выделить всё
$username=''; $token=''; $client = new GuzzleHttp\Client(); $url = $endpoint.'/v4/domains:checkAvailability'; $headers = ['Authorization' => "$username:$token",'Content-Type' => 'application/json']; $data ='{"domainNames":["example.com"]}'; $data=json_decode($data,true); $res = $client->post($url,['headers' => $headers ,'form_params' => $data ]); 1-Authorization is missing some thing like basic
2-name.com required --data as string but Guzzle required it as array
correct way to pass the data
thanks
Источник: https://stackoverflow.com/questions/781 ... me-com-api
Мобильная версия