你可以参考微信开发平台里的内容进行详细设置,也就是设置好后台的接口地址,然后再定义好token值,这样才能实现你说的自动回复.需要注意的是域名必须进行备案,否则无法通过
关注时,触发一个事件,在逻辑里判断事件的类型并返回你想要的内容
首先你要找一个php mail的开源类,网上非常多,require引用;
在登录程序里面加上发送邮件的函数.
php
/*
方倍工作室?
这是一个很简单的微信开发程序
*/
//定义TOKEN常量
define("TOKEN",?"weixin");
//实例化wechatCallbackapiTest这个类
$wechatObj?=?new?wechatCallbackapiTest();
/**如果有get传参echostr,则调用valid方法,否则调用responseMsg方法.responseMsg方法就是微信自动回复消息
**/
if?(isset($_GET['echostr']))?{
$wechatObj-valid();
}else{
$wechatObj-responseMsg();
}
//wechatCallbackapiTest类的定义
class?wechatCallbackapiTest
{
public?function?valid()
$echoStr?=?$_GET["echostr"];
if($this-checkSignature()){
echo?$echoStr;
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;
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();
$textTpl?=?"xml
ToUserName![CDATA[%s]]/ToUserName
FromUserName![CDATA[%s]]/FromUserName
CreateTime%s/CreateTime
MsgType![CDATA[%s]]/MsgType
Content![CDATA[%s]]/Content
FuncFlag0/FuncFlag
/xml";
if($keyword?==?"?"?||?$keyword?==?"")
$msgType?=?"text";
$contentStr?=?date("Y-m-d?H:i:s",time());
$resultStr?=?sprintf($textTpl,?$fromUsername,?$toUsername,?$time,?$msgType,?$contentStr);
echo?$resultStr;
echo?"";
以上就是土嘎嘎小编为大家整理的php自动回复客服源码相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!