WordsAPI

부분 유료
Verified
분류별 dpventures | 업데이트됨 5달 전 | Data
인기

9.9 / 10

지연 시간

176ms

서비스 수준

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