using php to make a asnc fetch then pass the results if good to js so I can hide the api_key

Exactly that. I am tying to use the youtube/google api so I can add videos to my site properly. However, I need a key to access all my videos, if I did not need that key I would just use js and not care. Like I said though, since I am forced to use that key, then I am trying to do the call in php and get a json file with all the videos and then use that to alter it in js file 🙂 is this possible
10 Replies
ἔρως
ἔρως2mo ago
why don't you try to read the rss feed instead?
clevermissfox
clevermissfox2mo ago
Is this in wordpress ?
MarkBoots
MarkBoots2mo ago
think the rss feed will only return a max of 15? Kevins channel; https://www.youtube.com/feeds/videos.xml?channel_id=UCJZv4d5rbIKd4QHMPkcABCw
ἔρως
ἔρως2mo ago
usually that is more than enough to show on the website, with a link to see the full channel
MarkBoots
MarkBoots2mo ago
true, but dont know what op wants. just pointing it out
ἔρως
ἔρως2mo ago
it is a good point the question says "all my videos" but the best way to show all the videos (possibly for free. without a backend) is through the channel
MarkBoots
MarkBoots2mo ago
the rss has a same origin policy. so that would require a proxy and if so, then just fetch it at the back end and only pass the format you need. much cleaner
ἔρως
ἔρως2mo ago
i didn't knew it has a same-origin policy that makes sense
MarkBoots
MarkBoots2mo ago
could be a simple script though. just fetch to your backend and let it get the rss, parse it and send it back
ἔρως
ἔρως2mo ago
using the feed also prevents the risk of being charged if the api key is over-used and abused by someone else

Did you find this page helpful?