本文整理汇总了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'];
}
示例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'];
}
示例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'];
}
示例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'];
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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'];
}
示例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;
}
示例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;
}
示例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'];
}
示例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;
}
示例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;
}