我正在尝试使用API在网站上显示youtube视频。为了从youtube上获取数据,我正在使用file_get_contents并对接收到的数据进行解码,我正在使用json_decode(),但是这些功能都无法正常工作。当我编写以下函数时:
file_get_contents('https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId='.$channelID.'&maxResults='.$maxResults.'&key='.$API_key.'')
我得到500错误。为什么会出现内部服务器错误?
而且,在错误日志文件中,我得到了这个
[2020-01-24 12:32:20]生产。错误:file_get_contents():https://包装在服务器配置中被allow_url_fopen = 0禁用(查看:/ home / project / project_laravel / resources / views /index.blade.php){“ exception”:“ [object](ErrorException(code:0):file_get_contents():https://包装在服务器配置中被allow_url_fopen = 0禁用(查看:/ home / project /home/project/project_laravel/storage/framework/views/2ef7c353b55ce1b10f018d5d4c745d8de5c15831.php:91,ErrorException(code:0):file_get_contents():https://包装器是/project_laravel/resources/views/index.blade.php)在服务器配置中由/home/project/project_laravel/storage/framework/views/2ef7c353b55ce1b10f018d5d4c745d8de5c15831.php:91上的allow_url_fopen = 0禁用[stacktrace]
[在研究期间,我已经在StackOverflow Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by all上尝试过此答案,用户已建议我们启用allow_url_fopen,但在我的php.ini中没有allow_url_fopen = 0。即使添加allow_url_fopen = 1
和allow_url_include = 1
我仍然收到此错误。
根据此答案Warning: file_get_contents(): https:// wrapper is disabled in the server configuration by all在php.ini中启用allow_url_fopen对我没有帮助。