I'm doing it the exact same way you're describing, with
file_get_contents($the_url), and it works fine for me. The only thing I can think of if it works in a browser but not on your server, is to make sure you're using a different API key that's a server key, where you'd be using a browser key to test from your browser, presumably. If that's not the issue, I can't think of any other obvious reason it shouldn't work.
YouTube API v3调用在浏览器中运行，代码失败
I'm trying to make a call from PHP to the YouTube API v3 to get the duration of a video. I've got my developer key, and have assembled what seems to be a valid URL, based on Google's docs and many other posts on SO:
I can enter this url into a browser, and a correct hunk of stuff comes back. But when I call it from PHP via
file_get_contents($the_url), it fails with a "Connection timed out" error.
I must be doing something wrong; any advice? Thanks!
1条回答 默认 最新
- 已采纳 dqlhsm9820 2016-02-15 07:33
I'm doing it the exact same way you're describing, with点赞 评论 复制链接分享