繁体   English   中英

为什么file_get_contents('external_url')在cron作业中不起作用? 有替代程序吗?

[英]why file_get_contents('external_url') is not working in cron job? Are there any alternate process?

我创建了一个php cron作业,以获取Instagram提要。 我的代码如下。

$homepage = file_get_contents("https://api.instagram.com/v1/users/XXXXXX/media/recent?access_token=XXXXXXXXXX.XXXXXXX.XXXXXX&count=8", false, stream_context_create($arrContextOptions)); $json = json_decode($homepage);

当我通过网络浏览器执行此代码时,它工作正常。 但是它不是从cron作业执行的。

我正在使用cron作业命令行,如下所示。

cd /home/MY_SITE/public_html/content/insta/ && php index.php > /dev/null 2>&1

请帮助我..谢谢。

也尝试将您的cron命令更改为此

php /home/MY_SITE/public_html/content/insta/index.php > /tmp/log

并检查/tmp/log文件是否可能记录了一些错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM