【发布时间】:2020-01-24 07:25:43
【问题描述】:
我正在尝试使用 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] production.ERROR: file_get_contents(): https:// wrapper is disabled in server configuration by allow_url_fopen=0 (查看:/home/project/project_laravel/resources/ views/index.blade.php) {"exception":"[object] (ErrorException(code: 0): file_get_contents(): https:// wrapper is disabled in server configuration by allow_url_fopen=0 (View: /home/项目/project_laravel/resources/views/index.blade.php)在/home/project/project_laravel/storage/framework/views/2ef7c353b55ce1b10f018d5d4c745d8de5c15831.php:91,ErrorException(代码:0):file_get_contents():https://wrapper在服务器配置中被 /home/project/project_laravel/storage/framework/views/2ef7c353b55ce1b10f018d5d4c745d8de5c15831.php:91 的 allow_url_fopen=0 禁用) [堆栈跟踪]
在研究过程中,我在 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
我仍然收到此错误。
【问题讨论】:
-
请发布日志错误消息。
-
请编辑您的帖子并包含错误信息
-
@TsaiKoga 我收到 500 错误页面。
-
是的,所以您需要发布错误消息。尝试在 storage/logs/laravel.log 中找到它
-
您可以使用 iframe 在网页上显示 youtube 视频。
标签: php laravel file-get-contents