php生手求微信PHP的注释
程序员文章站
2022-05-02 17:30:26
...
php新手求微信PHP的注释
/**
* wechat php test
*/
//define your token
define("TOKEN", "weixin");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
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;
$keyword = trim($postObj->Content);
$time = time();
$textTpl = "
%s
0
";
if(!empty( $keyword ))
{
$msgType = "text";
$contentStr = "Welcome to wechat world!";
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultStr;
}else{
echo "Input something...";
}
}else {
echo "";
/**
* wechat php test
*/
//define your token
define("TOKEN", "weixin");
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
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;
$keyword = trim($postObj->Content);
$time = time();
$textTpl = "
if(!empty( $keyword ))
{
$msgType = "text";
$contentStr = "Welcome to wechat world!";
$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
echo $resultStr;
}else{
echo "Input something...";
}
}else {
echo "";
相关文章
相关视频
上一篇: mysql_db_query 与mysql_query 查询区别
下一篇: php异常级别分析
推荐阅读
-
php微信开发之批量生成带参数的二维码,php批量参数_PHP教程
-
关于微店整合微信支付时出现的的各种问题的记录 php版
-
使用PHP进行微信公众平台开发的示例
-
浅谈使用PHP开发微信支付的流程,浅谈php支付流程_PHP教程
-
微信公众平台网页授权获取用户基本信息中授权回调域名设置的变动_PHP
-
php判断访问来源iphone,android,微信浏览器,pc电脑的方法
-
关于php微信的开发。
-
使用PHP进行微信公众平台开发的示例,php公众
-
PHP微信开发之微信消息自动回复下所遇到的坑_php实例
-
PHP微信开发之微信消息自动回复下所遇到的坑 微信漂流瓶自动回复 微信自动回复大全 微信群自动回