简体   繁体   English

Laravel Guzzle无法解析主机

[英]Laravel Guzzle Could Not Resolve Host

I have a Laravel application which is hosted locally on a local IP. 我有一个Laravel应用程序,该应用程序托管在本地IP上。

It will always be hosted internally on the IP. 它将始终在内部托管在IP上。

I'm trying to connect my application to Interlinks API, on sending a $client->post() I get the following error: 我试图将我的应用程序连接到Interlinks API,发送$ client-> post()时出现以下错误:

ConnectException in CurlFactory.php line 186: cURL error 6: Could not resolve host: headers (see http://curl.haxx.se/libcurl/c/libcurl-errors.html ) CurlFactory.php第186行中的ConnectException:cURL错误6:无法解析主机头(请参阅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). 尝试使用最新的Guzzle(目前为6.2)。

It seems that you are using older version, because setDefaultOption is not available in 6.x . 似乎您使用的是旧版本,因为setDefaultOption6.x不可用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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