本文整理汇总了PHP中ihttp_get函数的典型用法代码示例。如果您正苦于以下问题:PHP ihttp_get函数的具体用法?PHP ihttp_get怎么用?PHP ihttp_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ihttp_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getJsApiTicket
private function getJsApiTicket()
{
global $_W;
$data = array();
$wechat = pdo_fetch("SELECT access_token FROM " . tablename('wechats') . " WHERE weid = {$_W['weid']}");
$AccessToken = iunserializer($wechat['access_token']);
$now = time();
if ($AccessToken['expire'] < $now || !$AccessToken['ticket']) {
//失效时,从服务器获取最新的access_token和ticket
$res = ihttp_get("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$this->appId}&secret={$this->appSecret}");
$content = @json_decode($res['content'], true);
$access_token = $content['access_token'];
$res1 = ihttp_get("https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token={$access_token}");
$content1 = @json_decode($res1['content'], true);
$ticket = $content1['ticket'];
$data['token'] = $access_token;
$data['expire'] = $now + 7000;
//是7200秒失效,这里取7000
$data['ticket'] = $ticket;
pdo_update("wechats", array('access_token' => serialize($data)), array('weid' => $_W['weid']));
} else {
$ticket = $AccessToken['ticket'];
}
return $ticket;
}
示例2: getJsApiTicket
public function getJsApiTicket()
{
if (!empty($_W['account']['jsapi_ticket']) && is_array($_W['account']['jsapi_ticket']) && !empty($_W['account']['jsapi_ticket']['ticket']) && !empty($_W['account']['jsapi_ticket']['expire']) && $_W['account']['jsapi_ticket']['expire'] > TIMESTAMP) {
return $_W['account']['jsapi_ticket']['ticket'];
}
load()->func('communication');
$access_token = $this->getAccessToken();
if (is_error($access_token)) {
return $access_token;
}
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={$access_token}&type=jsapi";
$content = ihttp_get($url);
if (is_error($content)) {
return error(-1, '调用接口获取微信公众号 jsapi_ticket 失败, 错误信息: ' . $content['message']);
}
$result = @json_decode($content['content'], true);
if (empty($result) || intval($result['errcode']) != 0 || $result['errmsg'] != 'ok') {
return error(-1, '获取微信公众号 jsapi_ticket 结果错误, 错误信息: ' . $result['errmsg']);
}
$record = array();
$record['ticket'] = $result['ticket'];
$record['expire'] = TIMESTAMP + $result['expires_in'] - 200;
$row = array();
$row['jsapi_ticket'] = iserializer($record);
pdo_update('account_wechats', $row, array('acid' => $_W['account']['acid']));
$_W['account']['jsapi_ticket'] = $record;
return $record['ticket'];
}
示例3: getUserInfo
public function getUserInfo($access_token, $openid)
{
$api_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $openid . "&lang=zh_CN";
$content = ihttp_get($api_url);
$userInfo = @json_decode($content['content'], true);
return $userInfo;
}
示例4: respond
public function respond()
{
$content = $this->message['content'];
global $_W;
if (!$this->inContext) {
$this->beginContext(60);
return $this->respText('点击下方的“+”,发送您的地理位置。然后我们会返回您周边的酒店!');
} else {
if (isset($this->message['location_x']) && isset($this->message['location_y'])) {
$this->endContext();
load()->func('communication');
$data = ihttp_get("http://api.map.baidu.com/telematics/v3/local?location={$this->message['location_y']},{$this->message['location_x']}&keyWord=酒店&output=json&ak=jhSS7UjKAS9P9h2vDfhacjmr");
$data = json_decode($data['content'], true);
if ($data['status'] === 'Success') {
foreach ($data['pointList'] as $key => $val) {
if ((int) $key > 7) {
break;
}
$return[] = array('title' => $val['name'], 'description' => $val['address'], 'picurl' => '', 'url' => $val['additionalInformation']['link'][0]['url']);
}
return $this->respNews($return);
} else {
return $this->respText("没有查询结果。");
}
} else {
$this->endContext();
}
return false;
}
}
示例5: GetRouterInter
private function GetRouterInter($iur, $appid, $appkey, $nodeid, $openid)
{
$arrResult = array('flag' => 0, 'result' => '', 'token' => '', 'debug' => '');
$url = "{$iur}?appId={$appid}&appKey={$appkey}&nodeId={$nodeid}&openId={$openid}";
$rsp = ihttp_get($url);
$dat = $rsp['content'];
//获取接口情况
if (!empty($dat)) {
$result = json_decode($dat, true);
if (!is_array($result)) {
$arrResult['flag'] = 0;
$arrResult['result'] = '接口返回参数不是JSON格式';
$arrResult['debug'] = $dat;
} else {
if ($result['result'] == 'ok') {
$arrResult['flag'] = 1;
$arrResult['result'] = $result['url'];
$arrResult['token'] = $result['token'];
} elseif ($result['result'] == 'error') {
$arrResult['flag'] = -1;
$arrResult['result'] = $this->errcodetrans($result['errorCode']);
} else {
$arrResult['flag'] = 0;
$arrResult['result'] = '返回状态异常,请联系路由器接口提供方';
}
}
} else {
$arrResult['flag'] = 0;
$arrResult['result'] = '接口无响应';
$arrResult['debug'] = $url;
}
return $arrResult;
}
示例6: account_weixin_token
function account_weixin_token($account)
{
if (is_array($account['access_token']) && !empty($account['access_token']['token']) && !empty($account['access_token']['expire']) && $account['access_token']['expire'] > TIMESTAMP) {
return $account['access_token']['token'];
} else {
if (empty($account['weid'])) {
message('参数错误.');
}
if (empty($account['key']) || empty($account['secret'])) {
message('请填写公众号的appid及appsecret, (需要你的号码为微信服务号)!', create_url('account/post', array('id' => $account['weid'])), 'error');
}
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$account['key']}&secret={$account['secret']}";
$content = ihttp_get($url);
if (empty($content)) {
message('获取微信公众号授权失败, 请稍后重试!');
}
$token = @json_decode($content['content'], true);
if (empty($token) || !is_array($token)) {
message('获取微信公众号授权失败, 请稍后重试! 公众平台返回原始数据为: <br />' . $token);
}
if (empty($token['access_token']) || empty($token['expires_in'])) {
message('解析微信公众号授权失败, 请稍后重试!');
}
$record = array();
$record['token'] = $token['access_token'];
$record['expire'] = TIMESTAMP + $token['expires_in'];
$row = array();
$row['access_token'] = iserializer($record);
pdo_update('wechats', $row, array('weid' => $account['weid']));
return $record['token'];
}
}
示例7: getCardTicket
public function getCardTicket()
{
$cachekey = "cardticket:{$this->account['acid']}";
$cache = cache_load($cachekey);
if (!empty($cache) && !empty($cache['ticket']) && $cache['expire'] > TIMESTAMP) {
$this->account['card_ticket'] = $cache;
return $cache['token'];
}
load()->func('communication');
$access_token = $this->getAccessToken();
if (is_error($access_token)) {
return $access_token;
}
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={$access_token}&type=wx_card";
$content = ihttp_get($url);
if (is_error($content)) {
return error(-1, '调用接口获取微信公众号 card_ticket 失败, 错误信息: ' . $content['message']);
}
$result = @json_decode($content['content'], true);
if (empty($result) || intval($result['errcode']) != 0 || $result['errmsg'] != 'ok') {
return error(-1, '获取微信公众号 card_ticket 结果错误, 错误信息: ' . $result['errmsg']);
}
$record = array();
$record['ticket'] = $result['ticket'];
$record['expire'] = TIMESTAMP + $result['expires_in'] - 200;
$this->account['card_ticket'] = $record;
cache_write($cachekey, $record);
return $record['ticket'];
}
示例8: account_mechat_token
function account_mechat_token($acmechat)
{
if (is_array($acmechat['access_token']) && !empty($acmechat['access_token']['token']) && !empty($acmechat['access_token']['expire']) && $acmechat['access_token']['expire'] > TIMESTAMP) {
return $acmechat['access_token']['token'];
} else {
if (empty($acmechat['weid'])) {
message('参数错误.');
}
if (empty($acmechat['appid']) || empty($acmechat['appsecret'])) {
message('请填写开发者的appid及appsecret, (需要你的号码为美洽开发者)!', create_url('index/module/display', array('name' => 'mechat')), 'error');
}
$url = "http://open.mobilechat.im/cgi-bin/token?grant_type=client_credential&appid={$acmechat['appid']}&secret={$acmechat['appsecret']}";
$content = ihttp_get($url);
if (empty($content)) {
message('获取美洽开发者授权失败, 请稍后重试!');
}
$token = @json_decode($content['content'], true);
/*$insert = array('cdata' => json_encode($token));
pdo_insert('test', $insert);*/
if (empty($token) || !is_array($token)) {
message('获取美洽开发者授权失败, 请稍后重试! 公众平台返回原始数据为: <br />' . $token);
}
if (empty($token['access_token']) || empty($token['expire_in'])) {
message("解析美洽开发者授权失败. <br />URL:{$url}<br />错误代码为: {$token['errcode']} <br />错误信息为: {$token['errmsg']}");
}
$record = array();
$record['token'] = $token['access_token'];
$record['expire'] = TIMESTAMP + $token['expires_in'];
$row = array();
$row['access_token'] = iserializer($record);
pdo_update('mechat', $row, array('weid' => $acmechat['weid']));
return $record['token'];
}
}
示例9: __construct
public function __construct()
{
global $_W;
load()->func('communication');
$openid = $_W['openid'];
if (!empty($openid)) {
$account = account_fetch($_W['acid']);
//获取公众号信息
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $account['access_token']['token'] . "&openid=" . $openid . "&lang=zh_CN";
$re = ihttp_get($url);
//ihttp_get()封装的 http GET 请求方法
if ($re['code'] == 200) {
$content = json_decode($re['content'], true);
if ($content['subscribe'] == 1) {
//此人已关注
$data = array('uniacid' => $_W['uniacid'], 'from_user' => $openid, 'nickname' => $content['nickname'], 'avatar' => $content['headimgurl']);
$profile = pdo_fetch("SELECT id FROM " . tablename('auction_member') . " WHERE uniacid ='{$_W['uniacid']}' and from_user = '{$openid}'");
if (empty($profile)) {
pdo_insert('auction_member', $data);
} else {
pdo_update('auction_member', $data, array('id' => $profile['id']));
}
} else {
$userinfo = mc_oauth_userinfo();
$data = array('uniacid' => $_W['uniacid'], 'from_user' => $userinfo['openid'], 'nickname' => $userinfo['nickname'], 'avatar' => $userinfo['avatar']);
$profile = pdo_fetch("SELECT id FROM " . tablename('auction_member') . " WHERE uniacid ='{$_W['uniacid']}' and from_user = '{$userinfo['openid']}'");
if (empty($profile)) {
pdo_insert('auction_member', $data);
} else {
pdo_update('auction_member', $data, array('id' => $profile['id']));
}
}
}
}
}
示例10: cache_build_announcement
function cache_build_announcement()
{
$response = ihttp_get('http://www.we7.cc/api/v1/announcement.php');
$response['content'] = json_decode($response['content'], TRUE);
$cache = array('status' => $response['status'], 'content' => $response['content'], 'lastupdate' => TIMESTAMP);
cache_write('announcement', $cache);
}
示例11: ajaxsns
private function ajaxsns()
{
$msg = urlencode($this->message['content']);
$api = "http://api.ajaxsns.com/api.php?key=free&appid=0&msg=%s";
$dat = ihttp_get(sprintf($api, $msg));
return $dat;
}
示例12: fetchUserInfo
private function fetchUserInfo($openid)
{
$token = $this->fetchAccess();
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$token}&openid={$openid}&lang=zh_CN";
$response = ihttp_get($url);
if (is_error($response)) {
return error(-1, "访问公众平台接口失败, 错误: {$response['message']}");
}
$result = @json_decode($response['content'], true);
if (empty($result)) {
return error(-2, "接口调用失败, 错误信息: {$response}");
} elseif (!empty($result['errcode'])) {
return error(-3, "访问微信接口错误, 错误代码: {$result['errcode']}, 错误信息: {$result['errmsg']}");
}
$ret = array();
$ret['nickname'] = $result['nickname'];
$ret['gender'] = $result['sex'];
$ret['residecity'] = $result['city'];
$ret['resideprovince'] = $result['province'];
$ret['avatar'] = $result['headimgurl'];
if (!empty($ret['avatar'])) {
$ret['avatar'] = rtrim($ret['avatar'], '0');
$ret['avatar'] .= '132';
}
$ret['original'] = $result;
return $ret;
}
示例13: getUserInfo
public function getUserInfo($from_user)
{
$ACCESS_TOKEN = $this->getAccessToken();
$OPENID = $from_user;
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$ACCESS_TOKEN}&openid={$OPENID}&lang=zh_CN";
load()->func('communication');
$json = ihttp_get($url);
$userInfo = @json_decode($json['content'], true);
return $userInfo;
}
示例14: setbg
private function setbg($bg, $fan)
{
global $_W;
load()->func('communication');
load()->func('file');
$bg = tomedia($bg);
$file = ihttp_get($bg);
$file = $file['content'];
$img = '/images/' . $_W['uniacid'] . '/hx_qr/img/' . $fan['id'] . '.jpg';
file_write($img, $file);
return $img;
}
示例15: get_openid
public function get_openid($id, $code, $appid, $appsecret)
{
global $_GPC, $_W;
load()->func('communication');
$oauth2_code = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $appid . "&secret=" . $appsecret . "&code=" . $code . "&grant_type=authorization_code";
$content = ihttp_get($oauth2_code);
$token = @json_decode($content['content'], true);
if (!empty($token) && is_array($token) && $token['errmsg'] == 'invalid code') {
$this->get_code($id, $appid);
}
if (empty($token) || !is_array($token) || empty($token['access_token']) || empty($token['openid'])) {
message('未获取到 openid , 请刷新重试!');
}
return $token['openid'];
}