问题
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