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;
}
}
}
?>
원본 다운로드:와이퍼이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
laravel에 yo에서 angularJs&coffeescript를 사용할 수 있도록 한다.먼저 yo 명령을 사용할 수 있어야하므로 아래에서 설치 global에 설치한 곳에서 laravel의 프로젝트 루트로 이동. 클라이언트 코드를 관리하는 디렉토리를 만들고 이동합니다. 클라이언트 환경 만들기 이것으로 히...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.