WordsAPI

FREEMIUM
Verified
Por dpventures | Atualizado 5 months ago | Data
Popularidade

9.9 / 10

Latência

173ms

Nível de serviço

100%

Voltar para todas as discussões

php guzzle issue when requesting a response

avatar
tomasz.plewka66
a year ago

Hello, did anyone have an issue related to php guzzle and simple request call to word api?
This is what I intend to do:
use GuzzleHttp\Client;
use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Exception\RequestException;

client=newClient();client = new Client(); promise = client>requestAsync(GET,https://wordsapiv1.p.mashape.com/words/example,["headers"=>["xrapidapihost"=>"wordsapiv1.p.rapidapi.com","xrapidapikey"=>apikey]]);client->requestAsync('GET', 'https://wordsapiv1.p.mashape.com/words/example', [ "headers" => [ "x-rapidapi-host" => "wordsapiv1.p.rapidapi.com", "x-rapidapi-key" => apikey ] ]); promise->then(
function (ResponseInterface $res) {
echo $res->getStatusCode() . “\n”;
},
function (RequestException $e) {
echo $e->getMessage() . “\n”;
echo $e->getRequest()->getMethod();
}
);

$promise->wait();

However, it fails miserably with the following error:
Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 6: Could not resolve host: wordsapiv1.p.mashape.com (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)

Junte-se à discussão - adicione o comentário abaixo:

Efetue login / inscreva-se para postar novos comentários
Avaliação: 4 - Votos: 40