<del id="d4fwx"><form id="d4fwx"></form></del>
      <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

            <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
          • 微信公眾號(hào)生成新浪短網(wǎng)址的實(shí)現(xiàn)

            微信公眾號(hào)生成新浪短網(wǎng)址的實(shí)現(xiàn)?針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

            富蘊(yùn)網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,富蘊(yùn)網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為富蘊(yùn)上千多家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的富蘊(yùn)做網(wǎng)站的公司定做!

            <?php
            define("TOKEN", "xiao");
            //用于回復(fù)用戶消息
            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;
                $MsgT = $postObj->MsgType;
                $time = time();
                //如果用戶發(fā)的text類型
                if($MsgT=="text"){
                  $key = trim($postObj->Content);
                  $textTpl = "<xml>
                        <ToUserName><![CDATA[%s]]></ToUserName>
                        <FromUserName><![CDATA[%s]]></FromUserName>
                        <CreateTime>%s</CreateTime>
                        <MsgType><![CDATA[%s]]></MsgType>
                        <Content><![CDATA[%s]]></Content>
                        </xml>"; 
                  $msgType = "text";
            
                  //生成短網(wǎng)址
                  $dwzapi = "http://api.t.sina.com.cn/short_url/shorten.json?source=3271760578&url_long=".$key;
                  $dwzpost = file_get_contents($dwzapi);
                  $dwzjsondecode = json_decode($dwzpost,true);
            
                  //發(fā)送
                  $contentStr = $dwzjsondecode[0]['url_short'];
                  
            
                  $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                  echo $resultStr;
                  exit;
            
                }else{
                  $textTpl = "<xml>
                        <ToUserName><![CDATA[%s]]></ToUserName>
                        <FromUserName><![CDATA[%s]]></FromUserName>
                        <CreateTime>%s</CreateTime>
                        <MsgType><![CDATA[%s]]></MsgType>
                        <Content><![CDATA[%s]]></Content>
                        </xml>"; 
                  $msgType = "text";
                
                  //發(fā)送
                  $contentStr = "請(qǐng)發(fā)送鏈接";
                  
            
                  $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                  echo $resultStr;
                  exit;
                }
            
                //如果用戶發(fā)的event(事件)類型
                if($MsgT=="event"){
                  $Event = $postObj->Event;
                  if ($Event==subscribe) {
                    $contentStr = "歡迎關(guān)注";
                  }else{
                    $contentStr = "希望您下次關(guān)注,但您收不到此條消息了";
                  }
                  $textTpl = "<xml>
                        <ToUserName><![CDATA[%s]]></ToUserName>
                        <FromUserName><![CDATA[%s]]></FromUserName>
                        <CreateTime>%s</CreateTime>
                        <MsgType><![CDATA[%s]]></MsgType>
                        <Content><![CDATA[%s]]></Content>
                        </xml>"; 
                  $Title = $postObj->Title;
                  $Description = $postObj->Description;
                  $Url = $postObj->Url;
                  $msgType = 'text';
                  $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                  echo $resultStr;
                  exit;
                }
              }else{
                  echo "不對(duì)";
                  exit;
              }
            }
            
              $echoStr = $_GET["echostr"];
              //如果有$echoStr說(shuō)明是對(duì)接
              if (!empty($echoStr)) {
                //對(duì)接規(guī)則
                $signature = $_GET["signature"];
                $timestamp = $_GET["timestamp"];
                $nonce = $_GET["nonce"];
                $token = TOKEN;
                $tmpArr = array($token, $timestamp, $nonce);
                sort($tmpArr, SORT_STRING);
                $tmpStr = implode( $tmpArr );
                $tmpStr = sha1( $tmpStr );
                if( $tmpStr == $signature ){
                  echo $echoStr;
                }else{
                  echo "";
                  exit;
                }
              }else{
                responseMsg();
              }
            ?>

            配置方法:

            1、登錄公眾號(hào)
            2、打開基本配置

            微信公眾號(hào)生成新浪短網(wǎng)址的實(shí)現(xiàn)

            3、填寫上面代碼的url

            微信公眾號(hào)生成新浪短網(wǎng)址的實(shí)現(xiàn)

            關(guān)于微信公眾號(hào)生成新浪短網(wǎng)址的實(shí)現(xiàn)問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

            分享文章:微信公眾號(hào)生成新浪短網(wǎng)址的實(shí)現(xiàn)
            分享網(wǎng)址:http://www.jbt999.com/article10/ijjjdo.html

            成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站建設(shè)、面包屑導(dǎo)航靜態(tài)網(wǎng)站、搜索引擎優(yōu)化外貿(mào)網(wǎng)站建設(shè)

            廣告

            聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

            商城網(wǎng)站建設(shè)

              <del id="d4fwx"><form id="d4fwx"></form></del>
              <del id="d4fwx"><form id="d4fwx"></form></del><del id="d4fwx"><form id="d4fwx"></form></del>

                    <code id="d4fwx"><abbr id="d4fwx"></abbr></code>
                  • 亚洲— —在线 | 一本色道久久综合狠狠躁小说 | 天堂a| 色播在线永久免费视频 | 天天操天天撸视频免费 |