无论大转盘也好,或者是刮刮卡都是抽奖都可以利用同样的方法来计算中奖的概率和控制奖池的数量,本文为大家分享了PHP微信刮刮卡实例代码,PHP微信刮刮卡+接口,可直接调用,自带微信接口,供大家学习。
效果图:
prize.PHP
?>
<!DOCTYPE html>
<Meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <Meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no;"> <Meta name="apple-mobile-web-app-capable" content="yes"> <Meta name="apple-mobile-web-app-status-bar-style" content="black"> <Meta name="format-detection" content="telephone=no">sxxybbs_wx.php
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 = "
}else if($postObj->Content == '抽奖'){
$newsTpl ="
$url="http://2311156115.44c.pw/prize.php";
$resultStr = sprintf($newsTpl,$url);
echo $resultStr;
}else{
$keyword = trim($postObj->Content);
$textTpl = "
}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;
}
}
}
?>