我有一个codeigniter网络应用程序,我已经做了一个模型,它将在凸轮API上做一个打印屏幕的请求,脚本运行良好,这就是它:
<?php
class CronjobImagePrintScreenAPI extends CI_Model{
function __construct()
{
// Call the Model constructor
parent::__construct();
$this->load->library('curl');
$this->load->helper('file');
}
public function show_jobs(){
$flag = FALSE;
$query = $this->db->get('cron_jobs');
$query_result = $query->result();
if (empty($query_result)) {
$flag = FALSE;
}else{
$flag = TRUE;
}
if($flag === TRUE){
$datasidget = $this->curl->simple_get('myloginapi');
$datasid = json_decode($datasidget,true);
$data_sid = $datasid['data']['sid'];
$reqUrl = "myprintscreenapi";
$imageencode = $this->curl->simple_get($reqUrl);
$insert_id = $query_result[0]->name;
$path = "./images/$insert_id";
write_file($path, $imageencode, $mode = 'wb');
$this->db->where('name', $insert_id);
$this->db->delete('cron_jobs');
}
}
}
我想制作一个将每1分钟执行一次上述模型的cron,我知道如何做到这一点,我不知道是什么PHP脚本我必须写,以便运行该模型与cron,我做了一个像这样的控制器:
<?php
class Cronpicture extends CI_Controller {
public function __construct() {
parent:: __construct();
$this->load->helper('url','form');
$this->load->library('pagination');
$this->load->model('CronjobImagePrintScreenAPI');
}
public function getcronjob() {
$result=$this->CronjobImagePrintScreenAPI->show_jobs();
return $result;
}
}
?>
但是这显然不起作用,导致某些东西必须调用该函数。任何想法如何使可执行的PHP文件与cron一起运行以调用该模型函数?谢谢!
答案 0 :(得分:1)
你可以这样做:
fun animateHintTextColorChange(editText: EditText, colorFrom: Int, colorTo: Int, startDelay: Long = 0) : Animator {
val animator = ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo)
animator.duration = DURATION_MEDIUM
animator.startDelay = startDelay
animator.addUpdateListener { animator -> editText.setHintTextColor(animator.animatedValue as Int) }
return animator
}
或者只是做wget并使用网址
php /path_to_index/index.php Cronpicture getcronjob