<?php
/*
项目名称:在线简历填写+公众号简历状态实时推送查询系统
微信消息接口开发:@刘继鹏Beta
程序开发:@刘继鹏Beta
前端设计:@刘继鹏Beta
MYSQL:@刘继鹏Beta
开发日期:2017/02/13
*/
error_reporting(0);
define("TOKEN", "weixin");
$wechatObj = new wechatCallbackapiTest();
if (isset($_GET['echostr'])) {
$wechatObj->valid();
}else{
$wechatObj->responseMsg();
}
class wechatCallbackapiTest
{
public function valid()
{
$echoStr = $_GET["echostr"];
if($this->checkSignature()){
header('content-type:text');
echo $echoStr;
exit;
}
}
private function checkSignature()
{
$signature = $_GET["signature"];
$timestamp = $_GET["timestamp"];
$nonce = $_GET["nonce"];
$token = TOKEN;
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr, SORT_STRING);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature ){
return true;
}else{
return false;
}
}
public function responseMsg()
{
$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
if (!empty($postStr)){
$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
$fromUsername = $postObj->FromUserName;
$toUsername = $postObj->ToUserName;
$keyword = trim($postObj->Content);
$time = time();
$ev = $postObj->Event;
$con = mysql_connect ("localhost","root","root");
@mysql_select_db("jianli", $con);
mysql_query("SET NAMES UTF8");
$result = mysql_query("SELECT * FROM LJ_data WHERE opid LIKE '$fromUsername' limit 0,1 ");
while($row = mysql_fetch_array($result)) {
$sqlzhuangtai=$row['zhuangtai'];
$sqlxm=$row['xm'];
}
//关注的回复
if ($ev == "subscribe"){
$textTpl = "
%s
2
【1】直接回复‘简历’在线填写面试简历\r\n
【2】直接回复‘查询’获取简历审核状态\r\n
【3】更多优秀功能正在快马加鞭研发中
]]>
";
$msgType = "text";
$contentStr = "欢迎关注!";
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultStr;
}
//没有找到关键词的回复
if($num==0){$num="1";}
if($sda==""){$textTpl = "
%s
2
【1】直接回复‘简历’在线填写面试简历\r\n
【2】直接回复‘查询’获取简历审核状态\r\n
【3】更多优秀功能正在快马加鞭研发中
]]>
";
}
if(!empty( $keyword ))
{
$msgType = "news";
switch ($keyword)
{
case "简历";
$textTpl = "
点我在线填写简历]]>
";
break;
case "查询";
if($sqlzhuangtai=='审核中'){
$textTpl = "
%s
1
审核状态:审核中...\r\n
亲!你的简历正在人事MM处快马加鞭的审核中\r\n
无论审核通过与否我们都会在公众号内回复你\r\n
还请不要取消关注我们的公众号哟,谢谢合作]]>
";
}elseif($sqlzhuangtai=='通过'){
$textTpl = "
%s
1
审核状态:通过\r\n\n恭喜你已成功加入xx集团\n\n以下为注意事项\n\n以下为入职须知\n]]>
";
}elseif($sqlzhuangtai=='未通过'){
$textTpl = "
%s
1
审核状态:未通过\r\n\n很遗憾你没有通过本次面试\n\n祝你早日找到理想工作\n]]>
";
}else{
$textTpl = "
%s
1
";
}break;
}
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultStr;
}
}else {
echo "";
exit;
}
}
}
?>
一键复制
编辑
Web IDE
原始数据
按行查看
历史