PHP 위 챗 스 크 래 치 부 위 챗 인터페이스

룰렛 이 든 스 크 래 치 카드 든 모두 추첨 이 든 똑 같은 방법 으로 당 첨 확률 과 상금 의 수량 을 계산 할 수 있 습 니 다.본 고 는 PHP 위 챗 스 크 래 치 인 스 턴 스 코드,PHP 위 챗 스 크 래 치 카드+인 터 페 이 스 를 공유 하여 직접 호출 할 수 있 고 위 챗 인터페이스 가 있어 서 여러분 에 게 배 울 수 있 습 니 다.
효과 그림:

prize.php

<?php
$rand = rand(1,100);
if($rand<10){
 $prize = '  1 ';
}else if($rand<30){
 $prize = '  2 ';
}else if($rand<60){
 $prize = '  3 ';
}else{
 $prize = '    ';
}

?>

<!DOCTYPE html>
<html>
 <head>
 <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">
 <title>   </title>
 <link href="index/activity-style.css" rel="stylesheet" type="text/css">
 </head>
 
 </head>
 <body data-role="page" class="activity-scratch-card-winning">
 <script src="index/jquery.js" type="text/javascript"></script>
 <script src="index/wScratchPad.js" type="text/javascript"></script>
 <div class="main">
 <div class="cover">
 <img src="index/activity-scratch-card-bannerbg.png"> 
 <div id="prize"><?php echo $prize;?></div>
  <div id="scratchpad"></div>  
 </div>
 
 <div class="boxcontent boxwhite">
 <div class="box">
 <div class="title-brown">
 <span>
     :
 </span>
 </div>
 <div class="Detail">
 <p>
    : iphone 5S     :60
 </p>
 <p>
    : ipad mini2     :100
 </p>
 <p>
    :    16G        :2000
 </p>
 </div>
 </div>
 </div>
 
 <div class="boxcontent boxwhite">
 <div class="box">
 <div class="title-brown">
     :
 </div>
 <div class="Detail">
 <p class="red">
                 ,               !
 </p>
 <p>
  ,     !<a href="http://2311156115.44c.pw/prize.php">    </a>
 </p>
 </div>
 </div>
 </div>
 </div>
 <div style="clear:both;">
 </div>
 </div>
 
 <script type="text/javascript">
 window.sncode = "null";
 $(function() {
 $("#scratchpad").wScratchPad({
 width: 150,
 height: 40,
 color: "#a9a9a7",
 
 });
 });
 </script>
 
 </body>

</html>
sxxybbs_wx.php

<?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 = "<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 = "    :1";
 $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
   echo $resultStr;
 
 }else if($postObj->Content == '  '){
 $newsTpl ="<xml>
  <ToUserName><![CDATA[%s]]></ToUserName>
  <FromUserName><![CDATA[%s]]></FromUserName>
  <CreateTime>%s</CreateTime>
  <MsgType><![CDATA[news]]></MsgType>
  <ArticleCount>1</ArticleCount>
  <Articles>
  <item>
  <Title><![CDATA[     ]]></Title> 
  <Description><![CDATA[       ,   !]]></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 = "   :'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;
 }
 }
}

?>
원본 다운로드:와이퍼
이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기