WordsAPI

FREEMIUM
Verified
Door dpventures | Bijgewerkt 5 महीने पहले | Data
Populariteit

9.9 / 10

Latency

172ms

Serviceniveau

100%

Terug naar alle discussies

php guzzle issue when requesting a response

avatar
tomasz.plewka66
एक वर्ष पहले

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)

Doe mee aan de discussie - voeg hieronder een opmerking toe

Log in / Schrij u in om nieuwe opmerkingen te plaatsen
Beoordeling: 4 - Stemmen: 40