WeChat public platform development, external call interface to the parameter, and then the parameters in the form of text reply

Source: Internet
Author: User
Tags cdata
Public platform development, external call interface in the form of a URL, and then write the user's attention to the text after the reply, the URL of the image is passed over the parameters
。 But I didn't get the parameters when I was concerned.

http://xxx.duapp.com/wechat/api.php?id=http://203.111.111.111:1212/img/635932895447623934.png  代码如下:
  
   
    • wechat php test
      */
      //define your token

    $imgurl = $_GET['id'];

    define("TOKEN", "weixin");
    $wechatObj = new wechatCallbackapiTest();
    $wechatObj->responseMsg();

    1. wechatCallbackapiTest
      {

       Public Function Valid () {$echoStr = $_get["Echostr"]; Valid signature, option if ($this->checksignature ()) {echo $echoStr; Exit }} Public Function responsemsg () {//get post data, could 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 (); $imgurl = $_get[' id ']; $TEXTTPL = "     %s 0  %s   %s   %s   %s   "; $ev = $POSTOBJ->event; if ($ev = = "Subscribe") {$PicUrl = $imgurl; $URL = $imgurl; $TEXTTPL = "   %s  %s   %s   news  1  <! [cdata[Welcome to join Xlobo Technology]]> 贝海科技魔镜  {$PicUrl}  {$Url}      ";
       $RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time); Echo $resultStr; } if (!empty ($keyword)) { $msgType = "text"; Switch ($keyword) {case "1"; $CONTENTSTR = "Company profile!"; Break Case "2"; $CONTENTSTR = "Latest Offers!"; Break Case "3"; $CONTENTSTR = "The image link is as follows:". $_get[' id '); Break Default $CONTENTSTR = "Welcome!"; } $resultStr = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $conten TSTR); Echo $resultStr; }else{echo "Input something..."; } } else {echo ""; Exit }} Private Function Checksignature () {$signature = $_get["signature"]; $timestamp = $_get["timestamp"]; $nonce = $_get["nonce"]; $token = token; $TMPARR = Array ($token, $timestamp, $nonce); Sort ($TMPARR); $TMPSTR = implode ($TMPARR); $TMPSTR = SHA1 ($TMPSTR); if ($tmpStr = = $signature) {return true; }else{return false; } }

      }

      ?>

    Reply content:

    Public platform development, external call interface in the form of a URL, and then write the user's attention to the text after the reply, the URL of the image is passed over the parameters
    。 But I didn't get the parameters when I was concerned.

    http://xxx.duapp.com/wechat/api.php?id=http://203.111.111.111:1212/img/635932895447623934.png  代码如下:
      
        
    • wechat php test
      */
      //define your token

    $imgurl = $_GET['id'];

    define("TOKEN", "weixin");
    $wechatObj = new wechatCallbackapiTest();
    $wechatObj->responseMsg();

    1. wechatCallbackapiTest
      {

       Public Function Valid () {$echoStr = $_get["Echostr"]; Valid signature, option if ($this->checksignature ()) {echo $echoStr; Exit }} Public Function responsemsg () {//get post data, could 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 (); $imgurl = $_get[' id ']; $TEXTTPL = "     %s 0  %s   %s   %s   %s   "; $ev = $POSTOBJ->event; if ($ev = = "Subscribe") {$PicUrl = $imgurl; $URL = $imgurl; $TEXTTPL = "   %s  %s   %s   news  1  <! [cdata[Welcome to join Xlobo Technology]]> 贝海科技魔镜  {$PicUrl}  {$Url}      ";
       $RESULTSTR = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time); Echo $resultStr; } if (!empty ($keyword)) { $msgType = "text"; Switch ($keyword) {case "1"; $CONTENTSTR = "Company profile!"; Break Case "2"; $CONTENTSTR = "Latest Offers!"; Break Case "3"; $CONTENTSTR = "The image link is as follows:". $_get[' id '); Break Default $CONTENTSTR = "Welcome!"; } $resultStr = sprintf ($TEXTTPL, $fromUsername, $toUsername, $time, $msgType, $conten TSTR); Echo $resultStr; }else{echo "Input something..."; } } else {echo ""; Exit }} Private Function Checksignature () {$signature = $_get["signature"]; $timestamp = $_get["timestamp"]; $nonce = $_get["nonce"]; $token = token; $TMPARR = Array ($token, $timestamp, $nonce); Sort ($TMPARR); $TMPSTR = implode ($TMPARR); $TMPSTR = SHA1 ($TMPSTR); if ($tmpStr = = $signature) {return true; }else{return false; } }

      }

      ?>

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.