本文整理匯總了PHP中Http::curlGet方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::curlGet方法的具體用法?PHP Http::curlGet怎麽用?PHP Http::curlGet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Http
的用法示例。
在下文中一共展示了Http::curlGet方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isSub
function isSub($openid)
{
import('WechatApi');
$tokenObj = new WechatApi(array('appid' => option('config.wechat_appid'), 'appsecret' => option('config.wechat_appsecret')));
$access_token = $tokenObj->get_access_token();
$url = 'https://api.weixin.qq.com/cgi-bin/user/info?openid=' . $openid . '&access_token=' . $access_token['access_token'];
$classData = json_decode(Http::curlGet($url));
if ($classData->subscribe == 0) {
//沒有關注
return 0;
} else {
return 1;
}
}
示例2: img_download
public function img_download()
{
$url = $_POST['url'];
if (IS_POST && !empty($url)) {
$ext_name = strrchr($url, '.');
if ($ext_name != '.gif' && $ext_name != '.jpg' && $ext_name != '.png' && $ext_name != '.jpeg') {
json_return(1000, '為了網站安全考慮,<br/>網址應以(gif、jpg、png或jpeg)結尾');
}
import('Http');
$http_class = new Http();
$image_content = $http_class->curlGet($url);
if (empty($image_content)) {
json_return(1001, '沒有獲取到內容,請重試');
}
$img_store_id = sprintf("%09d", $this->store_session['store_id']);
$rand_num = 'images/' . substr($img_store_id, 0, 3) . '/' . substr($img_store_id, 3, 3) . '/' . substr($img_store_id, 6, 3) . '/' . date('Ym', $_SERVER['REQUEST_TIME']) . '/';
$upload_dir = './upload/' . $rand_num;
if (!is_dir($upload_dir)) {
mkdir($upload_dir, 0777, true);
}
$filename = uniqid() . $ext_name;
if (file_put_contents($upload_dir . $filename, $image_content)) {
$info = getimagesize($upload_dir . $filename);
$ext = image_type_to_extension($info['2']);
if (!in_array($ext, array('.gif', '.jpg', '.jpeg', '.png'))) {
unlink($upload_dir . $filename);
json_return(1002, '圖片格式不允許<br/>隻允許上傳(gif、jpg、png或jpeg)格式的圖片');
}
$add_result = $this->attachment_add($filename, $rand_num . $filename, filesize($upload_dir . $filename));
if ($add_result['err_code']) {
unlink($upload_dir . $filename);
} else {
// 上傳到又拍雲服務器
$attachment_upload_type = option('config.attachment_upload_type');
if ($attachment_upload_type == '1') {
import('source.class.upload.upyunUser');
upyunUser::upload('./upload/' . $rand_num . $filename, '/' . $rand_num . $filename);
}
json_return(0, array('url' => getAttachmentUrl($rand_num . $filename), 'pigcms_id' => $add_result['pigcms_id']));
}
} else {
json_return(1001, '圖片保存失敗,請重試');
}
}
}
示例3: kuadi100
public static function kuadi100($url)
{
import('class.Http');
$content = Http::curlGet($url);
return $content;
}
示例4: weixin_back
public function weixin_back()
{
$referer = !empty($_SESSION['weixin']['referer']) ? $_SESSION['weixin']['referer'] : U('Home/index');
// if (isset($_GET['code']) && isset($_GET['state']) && ($_GET['state'] == $_SESSION['weixin']['state'])){
if (isset($_GET['code'])) {
unset($_SESSION['weixin']['state']);
import('ORG.Net.Http');
$http = new Http();
$return = $http->curlGet('https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $this->config['wechat_appid'] . '&secret=' . $this->config['wechat_appsecret'] . '&code=' . $_GET['code'] . '&grant_type=authorization_code');
$jsonrt = json_decode($return, true);
if ($jsonrt['errcode']) {
$error_msg_class = new GetErrorMsg();
$this->error_tips('授權發生錯誤:' . $error_msg_class->wx_error_msg($jsonrt['errcode']), U('Login/index'));
}
$return = $http->curlGet('https://api.weixin.qq.com/sns/userinfo?access_token=' . $jsonrt['access_token'] . '&openid=' . $jsonrt['openid'] . '&lang=zh_CN');
$jsonrt = json_decode($return, true);
if ($jsonrt['errcode']) {
$error_msg_class = new GetErrorMsg();
$this->error_tips('授權發生錯誤:' . $error_msg_class->wx_error_msg($jsonrt['errcode']), U('Login/index'));
}
/*優先使用 unionid 登錄*/
if (!empty($jsonrt['unionid'])) {
$this->autologin('union_id', $jsonrt['unionid'], $referer);
}
/*再次使用 openid 登錄*/
$this->autologin('openid', $jsonrt['openid'], $referer);
/*注冊用戶*/
$data_user = array('openid' => $jsonrt['openid'], 'union_id' => $jsonrt['unionid'] ? $jsonrt['unionid'] : '', 'nickname' => $jsonrt['nickname'], 'sex' => $jsonrt['sex'], 'province' => $jsonrt['province'], 'city' => $jsonrt['city'], 'avatar' => $jsonrt['headimgurl']);
$_SESSION['weixin']['user'] = $data_user;
$this->assign('referer', $referer);
$this->display();
} else {
$this->error_tips('訪問異常!請重新登錄。', U('Login/index', array('referer' => urlencode($referer))));
}
}
示例5: authorize_openid
public function authorize_openid()
{
if (empty($_GET["code"])) {
$_SESSION["weixin"]["state"] = md5(uniqid());
$customeUrl = $this->config["site_url"] . $_SERVER["REQUEST_URI"];
//用戶同意授權,獲取code
$oauthUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $this->config["wechat_appid"] . "&redirect_uri=" . urlencode($customeUrl) . "&response_type=code&scope=snsapi_base&state=" . $_SESSION["weixin"]["state"] . "#wechat_redirect";
redirect($oauthUrl);
exit;
} else {
if (isset($_GET['code']) && true == isset($_GET['state']) && $_GET['state'] == $_SESSION['weixin']['state']) {
unset($_SESSION['weixin']);
import('ORG.Net.Http');
$http = new Http();
//獲取access_token
$return = $http->curlGet("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $this->config["wechat_appid"] . "&secret=" . $this->config["wechat_appsecret"] . "&code=" . $_GET["code"] . "&grant_type=authorization_code");
$jsonrt = json_decode($return, true);
//授權失敗
if ($jsonrt["errcode"]) {
$error_msg_class = new GetErrorMsg();
$this->error_tips("授權發生錯誤:" . $error_msg_class->wx_error_msg($jsonrt["errcode"]), U("Home/index"));
}
//授權成功
if ($jsonrt["openid"]) {
$_SESSION["openid"] = $jsonrt["openid"];
$result = D("User")->autologin("openid", $jsonrt["openid"]);
if (empty($result['error_code'])) {
$now_user = $result['user'];
session('user', $now_user);
$this->user_session = session('user');
}
} else {
redirect(u('Home/index'));
}
} else {
redirect(u('Home/index'));
}
}
}
示例6: getAttachmentUrl
} else {
$artivce_list[$key]['url'] = $activity->createUrl($value, $value['model'], '1');
$artivce_list[$key]['image'] = getAttachmentUrl($value['image']);
}
}
json_return(0, $artivce_list);
break;
case 'neargoods':
$long = $_REQUEST['long'];
$lat = $_REQUEST['lat'];
if (empty($long) || empty($lat)) {
json_return(1, '沒有攜帶地理位置');
}
import('Http');
$http_class = new Http();
$callback = $http_class->curlGet('http://api.map.baidu.com/geoconv/v1/?coords=' . $long . ',' . $lat . '&from=1&to=5&ak=4c1bb2055e24296bbaef36574877b4e2');
$callback_arr = json_decode($callback, true);
if (empty($callback_arr['result']) || !empty($callback_arr['status'])) {
json_return(1, '地理位置解析錯誤,請重試!');
} else {
$long = $callback_arr['result'][0]['x'];
$lat = $callback_arr['result'][0]['y'];
}
$database_store_contact = D('Store_contact');
//$goods_list = D('')->table(array('Store_contact'=>'sc', 'Store'=>'s', 'Product' => 'p'))->field("`p`.*, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$lat}*PI()/180-`sc`.`lat`*PI()/180)/2),2)+COS({$lat}*PI()/180)*COS(`sc`.`lat`*PI()/180)*POW(SIN(({$long}*PI()/180-`sc`.`long`*PI()/180)/2),2)))*1000) AS juli")->where("`sc`.`store_id`=`s`.`store_id` AND `s`.`status`='1' and `p`.`is_recommend` = 1 AND p.supplier_id = 0")->group('p.store_id')->order("`juli` ASC")->limit(4)->select();
$goods_list = array();
$goods_list = D('')->table("Product as p")->join('Store as s ON s.store_id=p.store_id', 'LEFT')->join('Store_contact as sc ON sc.store_id=p.store_id', 'LEFT')->field("`p`.*, ROUND(6378.138 * 2 * ASIN(SQRT(POW(SIN(({$lat}*PI()/180-`sc`.`lat`*PI()/180)/2),2)+COS({$lat}*PI()/180)*COS(`sc`.`lat`*PI()/180)*POW(SIN(({$long}*PI()/180-`sc`.`long`*PI()/180)/2),2)))*1000) AS juli")->where("`s`.`status`='1' and `p`.`is_recommend` = 1 AND p.supplier_id = 0")->group('p.store_id')->order("`juli` asc")->limit(4)->select();
foreach ($goods_list as $key => &$value) {
/*if($value['juli'] > 200000){
unset($store_list[$key]);
} else {
示例7: wap_getStore
public function wap_getStore($store_id)
{
$store = $this->db->where(array('store_id' => $store_id, 'status' => 1))->find();
if (!empty($store)) {
$_SESSION['tmp_store_id'] = $store_id;
//解決用戶訪問不同店鋪重複授權生成新用戶問題
/*if (empty($_SESSION['wap_user']) && !empty($_COOKIE['uid'])) { //COOKIE中有用戶信息
$tmp_user = M('User')->checkUser(array('uid' => $_COOKIE['uid']));
if (!empty($tmp_user)) {
$_SESSION['wap_user'] = $tmp_user;
$tmp_seller = D('Store')->where(array('drp_supplier_id' => $store_id, 'uid' => $_COOKIE['uid'], 'status' => 1))->find();
if (!empty($tmp_seller)) {
$_SESSION['wap_drp_store'] = $tmp_seller;
if (!empty($tmp_seller['oauth_url'])) { //對接微店
$_SESSION['sync_user'] = true;
}
}
setcookie('uid', $_COOKIE['uid'], $_SERVER['REQUEST_TIME']+10000000, '/'); //延長cookie有效期
} else {
unset($_SESSION['sync_user']); //刪除同步標識
unset($_SESSION['wap_user']); //刪除用戶登錄狀態
}
}*/
//判斷是否為對接微店
if (!empty($store['oauth_url'])) {
if (!empty($_SESSION['wap_user']) && $_SESSION['wap_user']['store_id'] != $store_id) {
//非當前店鋪粉絲,重新授權登陸
unset($_SESSION['sync_user']);
//刪除同步標識
unset($_SESSION['wap_user']);
//刪除用戶登錄狀態
}
} else {
unset($_SESSION['sync_user']);
//非對接店鋪 刪除同步標識
}
//對接網站用戶授權登陸
//授權條件:非對接同步用戶,是對接店鋪,店鋪管理後台未登錄(不加此條件,店鋪管理後台的所有鏈接無法在pc端打開,都會跳轉授權)
if (empty($_SESSION['sync_user']) && !empty($store['oauth_url']) && empty($_SESSION['sync_store'])) {
$return_url = urlencode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
if (!empty($store['oauth_url'])) {
if (stripos($store['oauth_url'], '?') === false) {
redirect($store['oauth_url'] . '?return_url=' . $return_url . '&store_id=' . $store_id . '&token=' . $store['token']);
} else {
redirect($store['oauth_url'] . '&return_url=' . $return_url . '&store_id=' . $store_id . '&token=' . $store['token']);
}
}
} else {
if (empty($_SESSION['sync_user']) && empty($store['oauth_url']) && empty($_SESSION['store'])) {
//默認授權
//授權條件:非對接同步用戶,非對接店鋪,店鋪管理後台未登錄(不加此條件,店鋪管理後台的所有鏈接無法在pc端打開,都會跳轉授權)
/*是否移動端*/
$is_mobile = is_mobile();
/*是否微信端*/
$is_weixin = is_weixin();
//調試 清除登錄信息
//setcookie('pigcms_sessionid','',$_SERVER['REQUEST_TIME']-10000000,'/');
//$_SESSION = null;
//session_destroy();
/*如果是微信端,且配置文件中配置了微信信息,得到openid*/
if ($is_weixin && (empty($_SESSION['openid']) || empty($_SESSION['wap_user']))) {
//openid存在 通過openid查找用戶
if (!empty($_SESSION['openid'])) {
$userinfo = M('User')->get_user('openid', $_SESSION['openid']);
$_SESSION['wap_user'] = $userinfo['user'];
mergeSessionUserInfo(session_id(), $userinfo['user']['uid']);
unset($_SESSION['wap_drp_store']);
}
//用戶未登錄 調用授權獲取openid, 通過openid查找用戶,如果已經存在,設置登錄,如果不存在,添加一個新用戶和openid關聯
if (empty($_SESSION['wap_user'])) {
$customeUrl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//判斷店鋪是否綁定過認證服務號
$wx_bind = D('Weixin_bind')->where(array('store_id' => $store['store_id']))->find();
if (empty($_GET['code'])) {
$_SESSION['weixin']['state'] = md5(uniqid());
if (!empty($wx_bind) && $wx_bind['service_type_info'] == 2 && $wx_bind['verify_type_info'] == 0) {
$oauthUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $wx_bind['authorizer_appid'] . '&redirect_uri=' . urlencode($customeUrl) . '&response_type=code&scope=snsapi_userinfo&state=' . $_SESSION['weixin']['state'] . '&component_appid=' . option('config.wx_appid') . '#wechat_redirect';
} else {
//店鋪非認證服務號走總後台授權
$oauthUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . option('config.wechat_appid') . '&redirect_uri=' . urlencode($customeUrl) . '&response_type=code&scope=snsapi_userinfo&state=' . $_SESSION['weixin']['state'] . '#wechat_redirect';
}
redirect($oauthUrl);
exit;
} else {
if (isset($_GET['code']) && isset($_GET['state']) && $_GET['state'] == $_SESSION['weixin']['state']) {
unset($_SESSION['weixin']);
import('Http');
$http = new Http();
if (!empty($wx_bind) && $wx_bind['service_type_info'] == 2 && $wx_bind['verify_type_info'] == 0) {
$component_token = M('Weixin_bind')->get_access_token($store['store_id'], true);
$tokenUrl = 'https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=' . $wx_bind['authorizer_appid'] . '&code=' . $_GET['code'] . '&grant_type=authorization_code&component_appid=' . option('config.wx_appid') . '&component_access_token=' . $component_token;
} else {
$tokenUrl = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . option('config.wechat_appid') . '&secret=' . option('config.wechat_appsecret') . '&code=' . $_GET['code'] . '&grant_type=authorization_code';
}
$return = $http->curlGet($tokenUrl);
$jsonrt = json_decode($return, true);
if ($jsonrt['errcode']) {
$error_msg_class = new GetErrorMsg();
exit('授權發生錯誤:' . $jsonrt['errcode']);
}
//.........這裏部分代碼省略.........
示例8: Http
$data["msg"] = $langArray['update_ok'];
}
}
} else {
$data["msg"] = $langArray['update_none'];
}
}
}
} else {
if (substr(sprintf('%o', fileperms($_SERVER['DOCUMENT_ROOT'])), -4) != '0777') {
$data["msg"] = $langArray['update_server'];
} else {
require_once ROOT_PATH . '/classes/Http.class.php';
$http = new Http();
$url = $langArray['index'] . '/getversion';
$version = $http->curlGet($url);
$version = strstr($version, '[{');
$version = json_decode($version, 1);
$version = $version[0]["content"];
$link = langMessageReplace($langArray['update_add'], array('version' => $version));
if (file_exists("update.zip")) {
unlink('update.zip');
}
$state = getFile($link, $config['root_path'], 'update.zip', 0);
if ($state) {
$data["msg"] = $langArray['update_none'];
require_once $config['root_path'] . '/core/classes/pclzip.lib.php';
$zip = new PclZip($config['root_path'] . '/update.zip');
$zip->extract();
if ($zip->extract() == 0) {
$data["msg"] = $langArray['update_none'];
示例9: D
// dump($_SESSION);
$weixin_bind_info = D('Weixin_bind')->where(array('store_id' => $now_store['store_id']))->find();
// dump($weixin_bind_info);
if ($weixin_bind_info && $weixin_bind_info['wxpay_mchid'] && $weixin_bind_info['wxpay_key']) {
if (empty($_GET['code'])) {
$_SESSION['store_weixin_state'] = md5(uniqid());
//代店鋪發起獲取openid
redirect('https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $weixin_bind_info['authorizer_appid'] . '&redirect_uri=' . urlencode($config['site_url'] . $_SERVER['REQUEST_URI']) . '&response_type=code&scope=snsapi_base&state=' . $_SESSION['store_weixin_state'] . '&component_appid=' . $config['wx_appid'] . '#wechat_redirect');
} else {
if (isset($_GET['code']) && isset($_GET['state']) && $_GET['state'] == $_SESSION['store_weixin_state']) {
import('Http');
$component_access_token_arr = M('Weixin_bind')->get_access_token($now_store['store_id'], true);
if ($component_access_token_arr['errcode']) {
pigcms_tips('與微信通信失敗,請重試。');
}
$result = Http::curlGet('https://api.weixin.qq.com/sns/oauth2/component/access_token?appid=' . $weixin_bind_info['authorizer_appid'] . '&code=' . $_GET['code'] . '&grant_type=authorization_code&component_appid=' . $config['wx_appid'] . '&component_access_token=' . $component_access_token_arr['component_access_token']);
$result = json_decode($result, true);
if ($result['errcode']) {
pigcms_tips('微信返回係統繁忙,請稍候再試。微信錯誤信息:' . $result['errmsg']);
}
$storeOpenid = $result['openid'];
if (!D('Order')->where(array('order_id' => $nowOrder['order_id']))->data(array('useStorePay' => '1', 'storeOpenid' => $storeOpenid, 'trade_no' => date('YmdHis', $_SERVER['REQUEST_TIME']) . mt_rand(100000, 999999)))->save()) {
pigcms_tips('訂單信息保存失敗,請重試。');
}
$payMethodList['weixin']['name'] = '微信安全支付';
$payList[0] = $payMethodList['weixin'];
$useStorePay = true;
}
}
}
} else {