Why I can't access the google-cloud-vision apis with PHP?

671 views Asked by At

When I tested the google-vision-api, it showed below every time :

 Fatal error: Uncaught exception
 'Google\Cloud\Core\Exception\ServiceException' with message 'cURL
 error 7: (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in
 /Library/Server/Web/Data/Sites/localhost/gvision/vendor/google/cloud-core/RequestWrapper.php:245
 Stack trace: #0
 /Library/Server/Web/Data/Sites/localhost/gvision/vendor/google/cloud-core/RequestWrapper.php(150):
 Google\Cloud\Core\RequestWrapper->convertToGoogleException(Object(Google\Cloud\Core\Exception\ServiceException))
 #1 /Library/Server/Web/Data/Sites/localhost/gvision/vendor/google/cloud-core/RestTrait.php(96):
 Google\Cloud\Core\RequestWrapper->send(Object(GuzzleHttp\Psr7\Request),
 Array) #2
 /Library/Server/Web/Data/Sites/localhost/gvision/vendor/google/cloud-vision/Connection/Rest.php(59):
 Google\Cloud\Vision\Connection\Rest->send('images', 'annotate', Array)
 #3 /Library/Server/Web/Data/Sites/localhost/gvision/vendor/google/cloud-vision/VisionClient.php(269):
 Google\Cloud\Vision\Connection\Rest->annotate(Array) #4
 /Library/Server/Web/Data/Sites/local in
 /Library/Server/Web/Data/Sites/localhost/gvision/vendor/google/cloud-core/RequestWrapper.php
 on line 245

I followed the step on this page, and my code is just the example in google.

I'm in China now, but I have been using a VPN. It helps a lot if anybody can figure it out.

1

There are 1 answers

0
Gosling On BEST ANSWER

I have figured this out.The OS Server can't access the VPN. This is what it's introduction says:It is a separately sold operating system add-on which provides additional server programs along with management and administration tools for macOS. So I changed to use MAMP to replace it to set up a Apache server on my Mac.It works for me.