PHP微信刮刮卡 附微信接口
来源: 阅读:732 次 日期:2016-08-11 14:55:43
温馨提示: 小编为您整理了“PHP微信刮刮卡 附微信接口”,方便广大网友查阅!

无论大转盘也好,或者是刮刮卡都是抽奖都可以利用同样的方法来计算中奖的概率和控制奖池的数量,本文为大家分享了PHP微信刮刮卡实例代码,PHP微信刮刮卡+接口,可直接调用,自带微信接口,供大家学习。

效果图:

名单

prize.php

$rand = rand(1,100);

if($rand<10){

$prize = '苹果1个';

}else if($rand<30){

$prize = '苹果2个';

}else if($rand<60){

$prize = '苹果3个';

}else{

$prize = '谢谢参与';

}

?>

刮刮卡

奖项设置:

一等奖: iphone 5S 奖品数量:60

二等奖: ipad mini2 奖品数量:100

三等奖: 金士顿16G手机卡 奖品数量:2000

活动说明:

中奖用户请准确将收货地址发送给我,我们将以货到付款的方式邮寄给你!

亲,祝您好运哦!再来一次

Baidu
map

sxxybbs_wx.php

/**

* wechat php test

*/

//define your token

define("TOKEN", "wwwsxxybbscom");

$wechatObj = new wechatCallbackapiTest();

//$wechatObj->valid();

$wechatObj->responseMsg();

class wechatCallbackapiTest

{

public function valid()

{

$echoStr = $_GET["echostr"];

//valid signature , option

if($this->checkSignature()){

echo $echoStr;

exit;

}

}

public function responseMsg()

{

//get post data, May be due to the different environments

$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];

//extract post data

if (!empty($postStr)){

$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);

$fromUsername = $postObj->FromUserName;

$toUsername = $postObj->ToUserName;

$time = time();

if($postObj->Content == '1'){

$textTpl = "

%s

0

";

$msgType = 'text';

$contentStr = "你输入了:1";

$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);

echo $resultStr;

}else if($postObj->Content == '抽奖'){

$newsTpl ="

%s

1

<![CDATA[刮刮乐翻天]]>

0

";

$url="http://2311156115.44c.pw/prize.php";

$resultStr = sprintf($newsTpl, $fromUsername, $toUsername, $time,$url);

echo $resultStr;

}else{

$keyword = trim($postObj->Content);

$textTpl = "

%s

0

";

if(!empty( $keyword ))

{

$msgType = "text";

$contentStr = "请输入:'1‘或者‘抽奖'";

$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);

echo $resultStr;

}else{

$msgType = "text";

$contentStr = "谢谢你关注sxxybbs博客,后续有精彩的内容会第一时间发送给您!回复:'1‘或者‘抽奖'得到对应的服务";

$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);

echo $resultStr;

}

}

}else {

echo "";

exit;

}

}

private function checkSignature()

{

$signature = $_GET["signature"];

$timestamp = $_GET["timestamp"];

$nonce = $_GET["nonce"];

$token = TOKEN;

$tmpArr = array($token, $timestamp, $nonce);

sort($tmpArr);

$tmpStr = implode( $tmpArr );

$tmpStr = sha1( $tmpStr );

if( $tmpStr == $signature ){

return true;

}else{

return false;

}

}

}

?>

源码下载:刮刮卡

以上就是本文的全部内容,希望对大家的学习有所帮助

更多信息请查看 网络编程
手机网站地址: PHP微信刮刮卡 附微信接口
由于各方面情况的不断调整与变化, 提供的所有考试信息和咨询回复仅供参考,敬请考生以权威部门公布的正式信息和咨询为准!
最新信息
公考类
招聘类
各类考试
关于我们| 联系我们| 人才招聘| 网站声明| 网站帮助| 非正式的简要咨询| 简要咨询须知| 加入群交流| 手机站点| 投诉建议
工业和信息化部备案号:滇ICP备2023014141号-1 云南省教育厅备案号:云教ICP备0901021 滇公网安备53010202001879号 人力资源服务许可证:(云)人服证字(2023)第0102001523号
云南网警备案专用图标
联系电话:0871-65317125(9:00—18:00) 获取招聘考试信息及咨询关注公众号:
咨询QQ:526150442(9:00—18:00) 版权所有:
云南网警报警专用图标
Baidu
map