简体   繁体   中英

Laravel Guzzle Could Not Resolve Host

I have a Laravel application which is hosted locally on a local IP.

It will always be hosted internally on the IP.

I'm trying to connect my application to Interlinks API, on sending a $client->post() I get the following error:

ConnectException in CurlFactory.php line 186: cURL error 6: Could not resolve host: headers (see http://curl.haxx.se/libcurl/c/libcurl-errors.html )

Below is the code in my controller.

$client = new \GuzzleHttp\Client();

        $client->setDefaultOption('headers', array('Accept' => 'application/json', 'Content-Type' => 'application/json', 'GEOSESSION' => 'MTAuMjYuMy43asdasdasdasdTky'));
        $body = json_encode($job);

        $res = $client->post('https://api.interlinkexpress.com/shipping/shipment',['body' => $body]);

        dd($res);

Does anyone have any ideas why I get the could not resolve host? I'm hoping it's nothing to do with being local.

Thanks

Try to use the latest Guzzle (6.2 at the moment).

It seems that you are using older version, because setDefaultOption is not available in 6.x .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM