當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Curl::httpGet方法代碼示例

本文整理匯總了PHP中Curl::httpGet方法的典型用法代碼示例。如果您正苦於以下問題:PHP Curl::httpGet方法的具體用法?PHP Curl::httpGet怎麽用?PHP Curl::httpGet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Curl的用法示例。


在下文中一共展示了Curl::httpGet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: long2short

 public static function long2short($url)
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/shorturl?access_token=' . AccessToken::getAccessToken();
     $data = array('action' => 'long2short', 'long_url' => $url);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['short_url'];
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:7,代碼來源:Popularize.class.php

示例2: getIp

 public static function getIp()
 {
     $accessToken = AccessToken::getAccessToken();
     $url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=' . $accessToken;
     $res = Curl::httpGet($url);
     return Error::isError($res) ? false : $res['ip_list'];
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:7,代碼來源:WechatIp.class.php

示例3: getTemplateId

 public static function getTemplateId($template_id_short)
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=' . AccessToken::getAccessToken();
     $data = array('template_id_short' => $template_id_short);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['template_id'];
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:7,代碼來源:Template.class.php

示例4: uploadNews

 public static function uploadNews($articles)
 {
     /* 傳入data實例
        $articles[] = array(
            'thumb_media_id'=> $media_id,
            'author'=> '天王蓋地虎',
            'title'=> '這個我的測試消息',
            'content_source_url'=> 'our-class.cn',
            'content'=> '這是一個圖文摘要',
            'digest'=> '',
            'show_cover_pic'=> 1,
        );
        $articles[] = array(
            'thumb_media_id'=> $media_id,
            'author'=> '天王蓋地虎',
            'title'=> '這個我的測試消息',
            'content_source_url'=> 'our-class.cn',
            'content'=> '這是一個圖文摘要',
            'digest'=> '',
            'show_cover_pic'=> 1,
        );
        */
     $url = 'https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=' . AccessToken::getAccessToken();
     if (count($articles) > 10) {
         href('文章總數大於10');
         return false;
     }
     $data = array('articles' => $articles);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['media_id'];
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:31,代碼來源:Media.class.php

示例5: getuser

 static function getuser($begin_date, $end_date, $summary = true)
 {
     if ($summary) {
         $url = 'https://api.weixin.qq.com/datacube/getusersummary?access_token=' . AccessToken::getAccessToken();
     } else {
         $url = 'https://api.weixin.qq.com/datacube/getusercumulate?access_token=' . AccessToken::getAccessToken();
     }
     $data = array('begin_date' => $begin_date, 'end_date' => $end_date);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:11,代碼來源:Statistics.class.php

示例6: setImage

 public static function setImage($file, $kf_account)
 {
     if (!file_exists($file)) {
         href('文件不存在');
         return false;
     }
     $url = 'http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=' . AccessToken::getAccessToken() . '&kf_account=' . $kf_account;
     $data = array('filename' => $file);
     $data = array("media" => "@" . $file, 'form-data' => $data);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:12,代碼來源:CustomerServices.class.php

示例7: query

 public function query($url)
 {
     $result = array('status' => 0, 'data' => '', 'err' => '');
     $res = Curl::httpGet($this->_url . $url, false, true);
     if ($res['header']['http_code'] == 200) {
         $result['status'] = 1;
         $result['data'] = $res['body'];
     } elseif ($res['err'] != '') {
         throw new \Exception($res['err']);
     } else {
         $result['status'] = 0;
         $result['data'] = $res['body'];
     }
     return $result;
 }
開發者ID:ivan6king,項目名稱:elastic-php,代碼行數:15,代碼來源:Es.php

示例8: get

 public function get($id, $source = false)
 {
     $result = array('status' => 0, 'data' => '', 'err' => '');
     $url = $source == false ? $this->_url . $this->_name . '/' . $id : $this->_url . $this->_name . '/' . $id . '/_source';
     $res = Curl::httpGet($url, false, true);
     if ($res['header']['http_code'] == 200) {
         $result['status'] = 1;
         $result['data'] = $res['body'];
     } elseif ($res['err'] != '') {
         throw new \Exception($res['err']);
     } else {
         $result['status'] = 0;
         $result['data'] = $res['body'];
     }
     return $result;
 }
開發者ID:ivan6king,項目名稱:elastic-php,代碼行數:16,代碼來源:Document.php

示例9: addMedia

 public static function addMedia($file, $type = 'image', $info = array())
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . AccessToken::getAccessToken();
     if (!file_exists($file)) {
         href('文件不存在');
         exit;
     }
     $data = array('filename' => $file);
     if ($type == 'video') {
         $description = array('title' => $info['title'], 'introduction' => $info['introduction']);
         $data = array("media" => "@" . $file, 'form-data' => $data, 'type' => $type, 'description' => $description);
     } else {
         $data = array("media" => "@" . $file, 'form-data' => $data, 'type' => $type);
     }
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:17,代碼來源:Material.class.php

示例10: getJsApiTicket

 private static function getJsApiTicket()
 {
     $mmc = memcache_init();
     $ticketInfo = @$mmc->get('ticket');
     if (isset($ticketInfo['ticket']) && time() - $ticketInfo['expires'] < 7000) {
         return $ticketInfo['ticket'];
     }
     $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=" . AccessToken::getAccessToken();
     $res = Curl::httpGet($url);
     if (Error::isError($res)) {
         exit;
     }
     $data['ticket'] = $res['ticket'];
     $data['expires'] = time();
     //存入Memcache
     $mmc->set('ticket', $data, 7200);
     return $res['ticket'];
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:18,代碼來源:JSSDK.class.php

示例11: getAccessToken

 public static function getAccessToken()
 {
     $mmc = memcache_init();
     $accessTokenArr = @$mmc->get('accessToken');
     $accessToken = $accessTokenArr['access_token'];
     if (!isset($accessTokenArr['access_token']) || time() - $accessTokenArr['expires'] > 7200 - 100) {
         $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&' . 'appid=' . getConfig('WX')['appID'] . '&secret=' . getConfig('WX')['appsecret'];
         $res = Curl::httpGet($url);
         if (Error::isError($res)) {
             return false;
         }
         $res['expires'] = time();
         //存入Memcache
         $mmc->set('accessToken', $res, 7200);
         $accessToken = $res['access_token'];
     }
     return $accessToken;
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:18,代碼來源:AccessToken.class.php

示例12: callWebServer

 /**
  * 調用外部url
  * @param $queryUrl
  * @param $param
  * @param string $method
  * @return bool|mixed
  */
 public static function callWebServer($queryUrl, $param, $method = 'get')
 {
     if (empty($queryUrl)) {
         return false;
     }
     $method = strtolower($method);
     $ret = '';
     $param = empty($param) ? array() : $param;
     $curlObj = new Curl();
     if ($method == 'get') {
         $ret = $curlObj->httpGet($queryUrl, GAME_URL, $param);
     } elseif ($method == 'post') {
         $ret = $curlObj->httpPost($queryUrl, GAME_URL, $param);
     }
     if (!empty($ret)) {
         return json_decode($ret, true);
     }
     return true;
 }
開發者ID:ishawge,項目名稱:LX_Blog,代碼行數:26,代碼來源:curl.business.php

示例13: preview

 public static function preview($type, $touser, $media_id, $content = NULL)
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . AccessToken::getAccessToken();
     switch ($type) {
         case 'text':
             $data = '{
                         "touser":"' . $touser . '",
                         "text":{
                                "content":"' . $content . '"
                                },
                         "msgtype":"text"
                     }';
             break;
         case 'mpnews':
             $data = '{
                        "touser":"' . $touser . '",
                        "mpnews":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"mpnews"
                     }';
             break;
         case 'voice':
             $data = '{
                        "touser":"' . $touser . '",
                        "voice":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"voice"
                     }';
             break;
         case 'image':
             $data = '{
                        "touser":"' . $touser . '",
                        "image":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"image"
                     }';
             break;
         case 'mpvideo':
             $data = '{
                        "touser":"' . $touser . '",
                        "mpvideo":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"mpvideo"
                     }';
             break;
         case 'wxcard':
             $data = '{ "touser":"' . $touser . '",
                       "wxcard":{
                                "card_id":"' . $media_id . '",
                                 "card_ext": "{"code":"","openid":"","timestamp":"1402057159","signature":"017bb17407c8e0058a66d72dcc61632b70f511ad"}"
                                 },
                       "msgtype":"wxcard"
                     }';
             break;
         default:
             href('迷茫了');
             exit;
     }
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['msg_id'];
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:65,代碼來源:Mass.class.php

示例14: getAll

 public function getAll()
 {
     $res = Curl::httpGet($this->_url . '_cat/indices/', false, true);
     if ($res['header']['http_code'] == 200) {
         $result['status'] = 1;
         $result['data'] = $res['body'];
     } elseif ($res['err'] != '') {
         throw new \Exception($res['err']);
     } else {
         $result['status'] = 0;
         $result['data'] = $res['body'];
     }
     return $result;
 }
開發者ID:ivan6king,項目名稱:elastic-php,代碼行數:14,代碼來源:Index.php

示例15: getConfig

 public static function getConfig()
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=' . AccessToken::getAccessToken();
     $res = Curl::httpGet($url);
     return Error::isError($res) ? false : $res;
 }
開發者ID:lxpfigo,項目名稱:blog,代碼行數:6,代碼來源:Menu.class.php


注:本文中的Curl::httpGet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。