cURL error 7: Failed to connect to maps.googleapis.com port 443

我们两清 提交于 2019-12-11 14:42:20

问题


I got following Error when get Distance between two places in Laravel. i use guzzlehttp/guzzle package to get Google Map api response. i previously declare use GuzzleHttp\Client; How to solve this Issue.

Error : cURL error 7: Failed to connect to maps.googleapis.com port 443: Network is unreachable (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

$pickupaddress = urlencode($frmplace);
$deliveryaddress = urlencode($destplace);
$client = new GuzzleHttp\Client();

$disrequest = $client->get('https://maps.googleapis.com/maps/api/distancematrix/json?origins='.$pickupaddress.'&destinations='.$deliveryaddress.'&mode=driving&key=ASESdsfsdfsdfdsfdf')->getBody();

$disjsondecode = json_decode($disrequest);
$tripdistance = $disjsondecode->rows[0]->elements[0]->distance->text;

回答1:


CURL ERROR NO 7 Issue occur in two cases : 1. Your server blocked port for security reasons. so you can ask to your server provider to enable it and server provider enabled to you. 2. Api provider does not accept different domain or some security or protected.

In your case Google disabled the service or pass credentials.

also use javascript library or google sdk.



来源:https://stackoverflow.com/questions/48921838/curl-error-7-failed-to-connect-to-maps-googleapis-com-port-443

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!