02 買粉絲買粉絲獲取token很慢(騰訊買粉絲公眾平臺給的token太長怎么解決哪位大神線上給我解決一下吧)

时间:2024-05-20 21:47:32 编辑: 来源:

;

                $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>

                            <FuncFlag>0</FuncFlag>

                            </xml>";             

                if(!empty( $keyword ))

                {

                      $msgType = "text";

                    $買粉絲ntentStr = "Wel買粉絲e to wechat world!";

                    $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $買粉絲ntentStr);

                    echo $resultStr;

                }else{

                    echo "Input something...";

                }

        }else {

            echo "";

            exit;

        }

    }

        

    private function checkSignature()

    {

        // you must define TOKEN by yourself

        if (!defined("TOKEN")) {

            throw new Exception('TOKEN is not defined!');

        }

        

        $signature = $_GET["signature"];

        $timestamp = $_GET["timestamp"];

        $nonce = $_GET["nonce"];

                

        $token = TOKEN;

        $tmpArr = array($token, $timestamp, $nonce);

        // use SORT_STRING rule

        sort($tmpArr, SORT_STRING);

        $tmpStr = implode( $tmpArr );

        $tmpStr = sha1( $tmpStr );

        

搜索关键词: