您好,欢迎访问一九零五行业门户网

微信大众平台接口

微信公众平台接口
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;
                $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 qianshouerror;

其它类似信息

推荐信息