示例#1
0
<?php

$devid = $_GET["devid"];
$msg = $_GET["max"];
if (empty($devid)) {
    $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
    $obj = json_decode($postStr);
    $devid = $obj->devid;
    $max = $obj->max;
}
if (empty($devid)) {
    die(json_encode(array("ret" => -1, "msg" => "no devid")));
}
include "qmc.php";
$out = QMC::output($devid, $max);
echo json_encode(array("ret" => 0, "result" => $out));
示例#2
0
function zan_send()
{
    global $db;
    // echo 'empty--->11list';
    $list = QMC::output("upzan", 1);
    //读取队列
    echo '<br>zan_send--->list<br>';
    // $list = array('ff9e537dbea1b731de24c85116a2fff8#["128"]');
    print_r($list);
    if (!empty($list)) {
        $value = $list[0];
        $valuearr = explode("#", $value);
        if (!empty($valuearr[0]) || !empty($valuearr[1])) {
            $from = trim($valuearr[0]);
            $res_from = $db->row_select_one("user", "umd5 = '{$from}' ", " name , headurl , sex, age");
            $from_name = $res_from['name'];
            $from_sex = $res_from['sex'] == 1 ? '男' : '女';
            $from_age = $res_from['age'];
            $headurl = $res_from['headurl'];
            $gushi_id_json = trim($valuearr[1]);
            $itemzanarr = json_decode($gushi_id_json);
            foreach ($itemzanarr as $item) {
                $res = $db->row_select_one("gushi", " id = '{$item}'  ", " umd5 , content");
                //
                $to = $res['umd5'];
                echo $to . "--->send<br>";
                $content_gushi = $res['content'];
                $slstr = strCut($content_gushi, 31);
                $content['headurl'] = $headurl;
                $content['username'] = $from_name;
                $ext = array("attr" => "card", "content" => $from_sex . "  " . $from_age . "岁  \n\n ta  赞了您的相册 \n" . $slstr, "user" => $from);
                //echo $from_name;
                $sendlog = send_card($to, $content, $ext);
                //print_r($sendlog);
            }
        }
    } else {
        echo 'zan_send--->empty';
    }
}
示例#3
0
<?php

include 'duilie.php';
$key = "duilie";
$value = "duilie_value";
for ($i = 0; $i < 100; $i++) {
    //QMC::input($key, $i);//写入队列
}
for ($i = 0; $i < 100; $i++) {
    $list = QMC::output($key, 1);
    //读取队列
    print_r($list);
}
示例#4
0
<?php

$key = "aaa";
$value = 'sunshine:' . time();
QMC::input($key, $value);
//写入队列
QMC::input($key, $value);
//写入队列
QMC::input($key, $value);
//写入队列
$list = QMC::output($key);
//读取队列
var_dump($list);
/** 
* Memcache 消息队列类 
*/
class QMC
{
    const PREFIX = 'ASDFASDFFWQKE';
    /** 
    * 初始化mc 
    * @staticvar string $mc 
    * @return Memcache 
    */
    private static function mc_init()
    {
        static $mc = null;
        if (is_null($mc)) {
            $mc = new Memcache();
            $mc->connect('127.0.0.1', 11211);
        }