Whether a big turntable or a scraping card is a lottery, you can use the same method to calculate the probability of winning and the number of control prize pools, this article for you to share the PHP micro-letter Scraping card instance code, PHP micro-letter Scraping card + interface, can be directly invoked, with a micro-letter interface for everyone to learn.
Effect Chart:
prize.php
<?php $rand = rand (1,100); if ($rand <10) {$prize = ' Apple 1 ';} else if ($rand <30) {$prize = ' Apple 2 ';} else if ($rand <60) {$prize = ' Apple 3 ';}
else{$prize = ' Thank you for participating ';} ?> <! DOCTYPE html>
sxxybbs_wx.php
<?php/** * WeChat PHP Test * *//define Your token ("define", "token");
$WECHATOBJ = new Wechatcallbackapitest ();
$WECHATOBJ->valid ();
$WECHATOBJ->responsemsg ();
Class Wechatcallbackapitest {public function valid () {$echoStr = $_get["Echostr"];
Valid signature, option if ($this->checksignature ()) {echo $echoStr;
Exit The Public Function responsemsg () {//get post data, May is due to the different environments $postStr = $GLOBALS ["H
Ttp_raw_post_data "]; Extract post Data if (!empty ($POSTSTR)) {$POSTOBJ = simplexml_load_string ($postStr, ' simplexmlelement ', Libxml_noc
DATA);
$fromUsername = $POSTOBJ->fromusername;
$toUsername = $POSTOBJ->tousername;
$time = time (); if ($postObj->content = = ' 1 ') {$textTpl = ' <xml> <tousername><![ Cdata[%s]]></tousername> <fromusername><! [cdata[%s]]></fromusername> <CreateTime>%s</CreateTime> <msgtype><! [CDATA[%S]]></msgtype> <content><!
[cdata[%s]]></content> <FuncFlag>0</FuncFlag> </xml> ";
$msgType = ' text ';
$CONTENTSTR = "One entered: 1";
$RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $CONTENTSTR);
Echo $resultStr; }else if ($postObj->content = = ' Draw ') {$newsTpl = "<xml> <tousername><![ Cdata[%s]]></tousername> <fromusername><! [cdata[%s]]></fromusername> <CreateTime>%s</CreateTime> <msgtype><! [cdata[news]]></msgtype> <ArticleCount>1</ArticleCount> <Articles> <item> <tit le><! [cdata[Scraping]]></title> <description><! [Cdata[I'm going to scratch the lottery! ]]></description> <picurl><! [cdata[http://special.sxcq.cn/cj/weixin/ggk/ggk.jpg]]></picurl> <url><! [cdata[%s]]></url> </item> </Articles> <FuncFlag>0</FuncFlag> </XML≫ ";
$url = "http://2311156115.44c.pw/prize.php";
$RESULTSTR = sprintf ($NEWSTPL, $fromUsername, $toUsername, $time, $url);
Echo $resultStr;
}else{$keyword = Trim ($postObj->content); $TEXTTPL = "<xml> <tousername><! [cdata[%s]]></tousername> <fromusername><! [cdata[%s]]></fromusername> <CreateTime>%s</CreateTime> <msgtype><! [cdata[%s]]></msgtype> <content><!
[cdata[%s]]></content> <FuncFlag>0</FuncFlag> </xml> ";
if (!empty ($keyword)) {$msgType = "text";
$CONTENTSTR = "Please enter: ' 1 ' or ' Draw '";
$RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $CONTENTSTR);
Echo $resultStr;
}else{$msgType = "text"; $CONTENTSTR = "Thank you for your concern Sxxybbs blog, the following has wonderful content will be the first time sent to you!"
Reply: ' 1 ' or ' lottery ' gets the corresponding service;
$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;
}}}?>
SOURCE Download: Scraping card
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.