1
votes

I am using a little bit older version of the PHP package of cloud-vision library, 0.19.0, because of some other dependency issues with other packages. This might be the cause of the problem, but I am not sure.

When working on localhost, I make a request and it all goes well, vision API returns the valid responses, but when I deployed to production, every time I try to use it, it just returns an error.

"message": "Request must specify image and features., "code": 3,"status": "INVALID_ARGUMENT","details": []

Is it the old package, or is something else the problem here? I ran out of ideas.

I am using a PHP library, so the code is pretty simple,I use the

file_get_contents($imageUrl)

and pass that string to the following functions enter image description here

1
The likeliest cause is that $imageUrl doesn't point to a valid image. Have you made absolutely certain that the path you're using is correct? Is the URI a local path or a remote URI? In certain PHP configurations, file_get_contents() will not work for remote URIs. Refer to the docs for info on that: php.net/file_get_contents. If you are fetching a remote file, try using curl or another utility to download it. - jdp
According to the (canonical error codes for Google APIs)[cloud.google.com/vision/docs/reference/rest/v1/Code] INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the system (e.g., a malformed file name). So, as jdp mentioned this could be related to an issue with your $imageUrl - Enrique Zetina
Thanks people, I logged the $imageUrl on production, and it was an access denied error from AWS. - Vedran Korponajić

1 Answers

1
votes

The problem was with building the $imageUrl on local/dev and production. I am using AWS, so the $imageUrl on dev was different than production, and the production url is returning an access denied.

Check your urls when working with AWS.