• php workerman定时任务


    一、下载workerman

              https://www.workerman.net/download
    

    二、下载workerman/mysql

              http://doc3.workerman.net/640201




    shipments.php用来写定时任务

    <?php
    /**
     * Created by PhpStorm.
     * User: Administrator
     * Date: 2018/11/29
     * Time: 16:59
     */
    
    use WorkermanWorker;
    use WorkermanLibTimer;
    
    require_once "Workerman/Autoloader.php";
    
    
    require_once "Connection.php";
    
    $task = new Worker();
    
    $task->onWorkerStart = function ($task) {
    
        global $db, $redis;
        $db    = new WorkermanMySQLConnection('127.0.0.1', '3306', 'root', 'root', 'test');
        $redis = new Redis();
        $redis->connect('127.0.0.1', 6379);
        $redis->auth("qqq123123.");
        $time_interval = 0.1;
        Timer::add($time_interval, function () {
            global $db, $redis;
            
            $insert['name'] = 123;
            
            $db->insert('shipments')->cols($insert)->query();
    
    //        sleep(100);
        });
    
    };
    
    
    function curlGet($url = '', $options = [])
    {
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        if (!empty($options)) {
            curl_setopt_array($ch, $options);
        }
        //https请求 不验证证书和host
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;
    }
    
    function newGetOrderInfo($taobao, $orderId)
    {
        $taobao = urlencode($taobao);
        $url    = "http://114.55.144.79/taobao/TradeFullinfoGetRequest.php?shop=$taobao&tid=$orderId";
        $json   = curlGet($url);
        return json_decode($json, true)['trade'];
    }
    
    Worker::runAll();
  • 相关阅读:
    Microsoft Excel 不能使用对象链接和嵌入的错误/cannot use object linking and enbedding
    (转)QML代码与现有Qt UI代码整合
    vs2012编译Qwt
    参数和返回类型也可以多态
    多态的运行
    调用哪个方法
    继承的意义
    设计继承树2
    设计继承树1
    了解继承
  • 原文地址:https://www.cnblogs.com/yszr/p/10825014.html
Copyright © 2020-2023  润新知