亚洲免费乱码视频,日韩 欧美 国产 动漫 一区,97在线观看免费视频播国产,中文字幕亚洲图片

      1. <legend id="ppnor"></legend>

      2. 
        
        <sup id="ppnor"><input id="ppnor"></input></sup>
        <s id="ppnor"></s>

        php微信開發(fā)之上傳臨時(shí)素材

        字號:


            本文實(shí)例為大家分享了php微信上傳臨時(shí)素材的具體代碼,供大家參考,具體內(nèi)容如下
            public function uploadImg($imgUrl){
              $TOKEN=$this->getAccessToken();
              $URL ='http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token='.$TOKEN.'&type=image';
              $data = array('media'=>'@'.$imgUrl);
              $result = $this->curl_post($URL,$data);
              $data = @json_decode($result,true);
              return $data['media_id'];
             }
             public function getAccessToken(){
              $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxe574b1bd35d7d4da&secret=d4624c36b6795d1d99dcf0547af5443d'; 
              $result = json_decode($this->curlGet($url),true);
              return $result['access_token'];
             }
             function curl_post($url, $data = null)
            {
             //創(chuàng)建一個(gè)新cURL資源
             $curl = curl_init();
             //設(shè)置URL和相應(yīng)的選項(xiàng) 
             curl_setopt($curl, CURLOPT_URL, $url);
             if (!empty($data)){
              curl_setopt($curl, CURLOPT_POST, 1);
              curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
             }
             curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
             //執(zhí)行curl,抓取URL并把它傳遞給瀏覽器
             $output = curl_exec($curl);
             //關(guān)閉cURL資源,并且釋放系統(tǒng)資源
             curl_close($curl);
             return $output;
            }
            調(diào)用uploadImg($imgurl) 傳圖片地址參數(shù)
            返回結(jié)果 
            array (
             'type' => 'image',
             'media_id' => 'W89mt3FEaxXOMOw0fLj2Cb6A8vfMjuXrj6XW59O3l9a7Tj_h2SjlBEr4dvp4Du2R',
             'created_at' => 1464140301,
            以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助