WordsAPI

फ्रीमियम
Verified
द्वारा dpventures | अपडेट किया गया 3 महीने पहले | Data
लोकप्रियता

9.9 / 10

लेटेंसी

175ms

सेवा का स्तर

100%

सभी चर्चाओं पर वापस जाएं

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)

चर्चा में शामिल हों - नीचे टिप्पणी जोड़ें:

नई टिप्पणियाँ पोस्ट करने के लिए लॉग इन / साइनअप करें
रेटिंग: 4 - वोट: 40