Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating youtube API in php on localhost

I'm developing a PHP app on my local computer and trying to use the public data API. The key has been generated and works well online, but as soon as I try to execute it on my localhost it returns

Access Not Configured. Please use Google Developers Console to activate the API for your project.

I have added these lines to the 'allowed referers' section in the developers console.

http://127.0.0.1
127.0.0.1
http://localhost/
localhost
http://myIpAddress
myIpAddress

None of them seem to help. This is the query sending via GET:

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=######&fields=items%2Fsnippet&key=#######
like image 384
Ivan Lesar Avatar asked Jun 14 '26 07:06

Ivan Lesar


1 Answers

My issue had nothing to do with the cases described here, but might help others.

I had a scenario where the API worked well online but not on localhost (WAMP), after migrating from old API.

The fix had to do with cURL, and I really can not explain why it did work online, I am not an expert, it's something related with SSL.

Basically, you need to turn of SSL verification, by using

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
like image 183
Hernan Avatar answered Jun 16 '26 21:06

Hernan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!