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

PHP 微信接口封装类_PHP教程

weixin_run(); //执行接收器方法   class wechatcallbackapitest {    private $fromusername;    private $tousername;    private $times;    private $keyword;            public function weixin_run(){      $this->responsemsg(); $arr[]=array(很靠谱,不错!,aa,http://www.chuangen.com/pic/hj/s_4.png,http://www.baidu.com); $arr[]=array(很靠谱,不错!,aa,http://www.chuangen.com/pic/hj/s_4.png,http://www.baidu.com); $arr[]=array(很靠谱,不错!,aa,http://www.chuangen.com/pic/hj/s_4.png,http://www.baidu.com); $this->fun_xml(news,$arr,array(2,0));     }           function t($n){    include(t_api.php);    $c_name=$t_api[$n];    $json=file_get_contents(http://m.weather.com.cn/data/101110310.html);    return json_decode($json);   }             public function valid()     {         $echostr = $_get[echostr];           //valid signature , option         if($this->checksignature()){          echo $echostr;          exit;         }     }       public function responsemsg()     { $poststr = $globals[http_raw_post_data]; if (!empty($poststr)){                $postobj = simplexml_load_string($poststr, 'simplexmlelement', libxml_nocdata);                 $this->fromusername = $postobj->fromusername;                 $this->tousername = $postobj->tousername;                 $this->keyword = trim($postobj->content); $this->times = time();         }else {          echo this a file for weixin api!;          exit;         }     }   //微信封装类, //type: text 文本类型, news 图文类型 //text,array(内容),array(id) //news,array(array(标题,介绍,图片,超链接),...小于10条),array(条数,id)   private function fun_xml($type,$value_arr,$o_arr=array(0)){  //=================xml header============  $con=fromusername}]]>tousername}]]>{$this->times};         //=================type content============  switch($type){      case text :   $con.={$o_arr};   break;   case news :   $con.={$o_arr[0]}; foreach($value_arr as $id=>$v){ if($id>=$o_arr[0]) break; else null; //判断数组数不超过设置数          $con.=  ; } $con.={$o_arr[1]};   break;    } //end switch   //=================end return============  echo $con.; }       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; } } }   ?>
http://www.bkjia.com/phpjc/735072.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/735072.htmltecharticle?php/** * 微信公众平台接口php100封装功能类文件 * author * date 2013-4-9 prc:e+8 23:03 */define(token, chuangenit);$wechatobj = new wechatcallbackapitest();$wechatobj-...
其它类似信息

推荐信息