json_encode($info) ); $post['ExtParameters'] = json_encode($ExtParameters); ksort($post); $qs = ''; $tosign = ''; foreach($post as $key => $v) { if($qs != '') $qs .= "&"; if($tosign != '') $tosign .= "&"; $qs .= $key ."=" .urlencode($v); $tosign .= rawurlencode($key) ."=" .rawurlencode($v); } $tosign = "GET&%2F&".rawurlencode($tosign); //echo $tosign."\n\n"; $sign = base64_encode(hash_hmac('sha1', $tosign, "NltQrgsfhQqzrLOwmaQ6fJEAODDCbr&", true)); $qs .= "&Signature=" . urlencode($sign); $url = "http://cloudpush.aliyuncs.com/?".$qs; $s = query($url); $a = json_decode($s, true); if($a['MessageId']) return $a['MessageId']; return false; } function sendTs($cellphone, $title, $content){ // $cellphone = "13630035336"; // $title = "测试"; // $content = "测试内容"; $MessageId1 = sendMethod($cellphone, $title, $content, array('')); $MessageId2 = sendMethod($cellphone, $title, $content, array(''), 'ios'); if($MessageId1 && $MessageId2){ return true; }else{ return false; } } function sendSms($mobile, $msg) { //echo $msg; //$mobile = "13392296312"; $appid = 'svcXhqBFtbvNS6GUVumSM8k0WarOLiOZ'; $appkey = 'ex1JUa3xO3JFXB9k5OqULKYYoJz7A2nV'; $msg = '【云中美食】'.$msg; $sign = md5($appid.$mobile.$msg.$appkey); $url = "https://sms.189ek.com/yktsms/send"; $c = curl_init($url); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($c, CURLOPT_POST, 1); curl_setopt($c, CURLOPT_POSTFIELDS, "appid={$appid}&mobile={$mobile}&msg=".urlencode($msg)."&sign={$sign}"); curl_setopt($c, CURLOPT_TIMEOUT, 10); $content = curl_exec($c); curl_close($c); return $content; } //$data = $db->get_all("select a.id, b.title,b.content,c.cellphone,c.username,c.deptname,c.id as uid, b.id as notice_id from tb_notice_push a, tb_notice b, tb_user c where a.notice_id=b.id and a.user_id=c.id and a.status=0 and b.status!=0 and c.enabled not in (0, -99) and b.ispush = 1 and b.sendtime < now()"); // //$nids = array(); //foreach($data as $item) { // $id = $item['id']; // $title = strip_tags($item['title']); // $content = strip_tags($item['content']); // $cellphone = $item['cellphone']; // $username = $item['username']; // $deptname = $item['deptname']; // $uid = $item['uid']; // $notice_id = $item['notice_id']; // $nids[$notice_id] = 1; // $data2 = array( // 'notice_id' => $notice_id, // 'user_id' => $uid, // 'title' => $title, // 'content' => $content, // ); // $MessageId1 = sendTs($cellphone, $title, $content, array('type' => '1', 'data' => $data2)); // $MessageId2 = sendTs($cellphone, $title, $content, array('type' => '1', 'data' => $data2), 'ios'); // echo $MessageId1."_".$MessageId2."\n"; // $db->query("update tb_notice_push set status=1,MessageId='{$MessageId1}_{$MessageId2}' where id=".$id); // //} // //foreach($nids as $notice_id => $v) { // $row = $db->query("select * from tb_notice_push where notice_id=".$notice_id." and status=0"); // $status = $row?2:3; // $db->query("update tb_notice set status={$status} where id={$notice_id} and status != 0"); //} //echo date("Y-m-d H:i:s ".count($data)."\n");