コード例 #1
0
ファイル: weixin.php プロジェクト: XinRan5312/webot
<?php

require 'config.php';
$wechatObj = new wechatCallbackapiTest();
$wechatObj->valid();
require 'ImagePoster.php';
$wechatObj->forwardToWeibo();
class wechatCallbackapiTest
{
    var $poster;
    public function valid()
    {
        $echoStr = $_GET["echostr"];
        //valid signature , option
        if ($this->checkSignature()) {
            echo $echoStr;
        }
    }
    public function forwardToWeibo()
    {
        $this->poster = new ImagePoster();
        //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);
            $msgType = $postObj->MsgType;
            $fromUsername = $postObj->FromUserName;
            $key = $fromUsername . 'key';
            $toUsername = $postObj->ToUserName;
            if ($msgType == 'image') {