【调度系统】广东民航医疗快线调度系统源代码
wzp
2024-12-05 8a09f655eace34e9c90bbfc711eedb7a69e4e068
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
 
<?php
$WXID=empty($_REQUEST['WXID'])!=false ? '1' : addslashes($_REQUEST['WXID']);
$action_name=empty($_REQUEST['action_name'])!=false ? '' : addslashes($_REQUEST['action_name']);//生成类型(临时、永久)
$create_num=empty($_REQUEST['create_num'])!=false ? 0 : addslashes($_REQUEST['create_num']);//生成数量
 
if ($WXID=="1"){
    //白马良仓服务号
    $AppId="wx8dffc05a6ada87ed";
    $AppSecret="c4b8f71b194da3a966a142fb0ab5f116";
}elseif ($WXID=="2"){
    //白马粮仓服务号
    $AppId="wx45e7e693c61afa0c";
    $AppSecret="da13626cdbd15f504a04cd2cacfd8b4c";
}elseif ($WXID=="3"){
    //白马良膳FW 
    $AppId="wxe04debc4d5df259d";
    $AppSecret="3c2070c39d86fc11af2e1612fa733926";
}elseif ($WXID=="4"){
    //白马良膳FW 
    $AppId="wxe84efd5e8164f936";
    $AppSecret="42d5b859422cab3347e5751fc403c42f";
}elseif ($WXID=="5"){
    //煮食会社 
    $AppId="wxdda1ae05482f6ff6";
    $AppSecret="60f6350b8b10c70879639384056ffa9e";
}else{
    exit;
}
 
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$AppId."&secret=".$AppSecret;
//echo $url."<br>";
$data = getCurl($url); //通过自定义函数getCurl得到https的内容
$resultArr = json_decode($data, true); //转为数组
$accessToken=$resultArr["access_token"]; //获取access_token
//echo $accessToken."<br>";
 
if (!empty($action_name)){
    $access_token=$accessToken; //获取access_token
    $json_url='http://api.weixin.qq.com/cgi-bin/qrcode/create?access_token='.$access_token;
 
    //数据库里查询最后生成一个编号
    //$now_secne_id=M('erweima')->where(array('token'=>$this->token))->order('scene_id desc')->getField('scene_id');
    $now_secne_id=0;
 
    //新生成在最后一个编辑上加1
    $start_secne_id=intval($now_secne_id)+1;
    $end_secne_id=intval($now_secne_id)+intval($create_num);
    $n=0;
    for($i=$start_secne_id;$i<=$end_secne_id;$i++){
        $curl_data='';
        if($action_name=='QR_SCENE'){
            //临时 post的json数据
            $curl_data='{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": '.$i.'}}}';
        }
 
        if($action_name=='QR_LIMIT_SCENE'){
            //永久 post的json数据
            $curl_data='{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": '.$i.'}}}';
        }
        $json_info=api_notice_increment($json_url,$curl_data);
        echo $json_info;
        /*
        $json_info=json_decode(api_notice_increment($json_url,$curl_data),true);
 
        //这里代表生成成功,记录数据以便插入到数据库,方便以后统计查找
        if($json_info['errcode']!=40013){
            echo $json_info['ticket']."";
            echo $accessToken."<br>";
            echo $json_info['ticket']."<br>";
            echo $json_info['url']."<br>";
            echo $i."<br>";
            echo $json_info['expire_seconds']."<br>";
            echo $action_name."<br><br>";
            /*
            $data[$n]['token']=$this->token;
            $data[$n]['tiket']=$json_info['ticket'];
            $data[$n]['url']=$json_info['url'];
            $data[$n]['scene_id']=$i;
            $data[$n]['expire_seconds']=$json_info['expire_seconds'];
            $data[$n]['action_name']=$action_name;
            $data[$n]['remark']='';
            $data[$n]['createtime']=time();
            
            $n++;
        }else{
            echo '操作失败<br><br>';
        }
        */
    }
}
 
 
function getCurl($url){//get https的内容
$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);//不输出内容
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $result = curl_exec($ch);
    curl_close ($ch);
    return $result;
}
 
function dataPost($post_string, $url) {//POST方式提交数据
    $context = array ('http' => array ('method' => "POST", 'header' => "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) \r\n Accept: */*", 'content' => $post_string ) );
    $stream_context = stream_context_create ( $context );
    $data = file_get_contents ( $url, FALSE, $stream_context );
    return $data;
}
 
function api_notice_increment($url, $data){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt( $ch , CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查  
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    curl_setopt($ch, CURLOPT_AUTOREFERER,true);
    $content = curl_exec($ch);
    $info = curl_getinfo($ch,CURLINFO_EFFECTIVE_URL); 
    $code = curl_getinfo($ch,CURLINFO_HTTP_CODE);       
    curl_close($ch);    
    if($code == "200"){
        return $content;
    }else{
        return "错误码:".$code;
    }
}
?>