Ejemplo n.º 1
0
<?php

require_once 'filter.php';
require_once 'shake2.php';
$action = $_GET['a'];
$shake = new Shake($config);
switch ($action) {
    case "get_prize":
        $uid = $_COOKIE[USER_COOKIE_ID];
        if ('frank' == $_GET['test']) {
            $uid = '9fd4eda2fb47e99e6daa206cc325bd9b';
        }
        $user = $shake->getUser($uid, $config['appid']);
        if (!$user) {
            echo json_encode(array('type' => -2, 'prize' => '用户信息读取失败'));
            exit;
        }
        $wecha_id = $user['openid'];
        // array($type,$prize) $type -1:活动暂未开始, 0:什么也没中,1:现金红包,2:购物卡,3:参与次数用完
        list($type, $prize) = $shake->get_user_prize($wecha_id);
        echo json_encode(array('type' => $type, 'prize' => $prize));
        break;
}
Ejemplo n.º 2
0
$shake = new Shake();
$uid = $_COOKIE[USER_COOKIE_ID];
$url = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $config["appid"] . '&redirect_uri=' . htmlspecialchars($config["redirect_uri"]) . '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
if ($uid) {
    $user = $shake->getUser($uid, $config['appid']);
    if (!$user || $user['expiretime'] < time()) {
        //用户不存在或者过期
        header("Location:" . $url);
        exit;
    }
} else {
    header("Location:" . $url);
    exit;
}
$wecha_id = $user['openid'];
$user_get_prize = $shake->get_user_prize($wecha_id);
$tip = "很遗憾,您没有中奖<br/>更多精彩活动<br/>请关注香江全球家居CBC官方微信";
$status = $shake->get_user_prize_status($user_get_prize);
if ($status == 3) {
    $tip = "您今日已领取过奖品<br/>" . $user_get_prize['prize_name'] . "<br/>谢谢参与";
} else {
    if ($status > 0) {
        $tip = "恭喜您<br/>已获得香江全球家居CBD<br/>" . $user_get_prize['prize_name'];
    }
}
?>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta http-equiv="Content-Type">
    <meta content="text/html; charset=utf-8">