本文整理汇总了PHP中http函数的典型用法代码示例。如果您正苦于以下问题:PHP http函数的具体用法?PHP http怎么用?PHP http使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了http函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_token
public function get_token()
{
if ($_GET['code'] != '') {
$code = $_GET['code'];
$oauth = 'https://api.weixin.qq.com/sns/oauth2/access_token';
$params['appid'] = C('APPID');
$params['secret'] = C('APPSECRET');
$params['code'] = $code;
$params['grant_type'] = 'authorization_code';
$result = http($oauth, $params);
if (!empty($result)) {
$result = json_decode($result);
$userinfo_url = 'https://api.weixin.qq.com/sns/userinfo';
unset($params);
$params['access_token'] = $result->access_token;
$params['openid'] = $result->openid;
$params['lang'] = 'zh_CN';
$userinfo = http($userinfo_url, $params);
$userinfo = json_decode($userinfo);
$unionid = empty($userinfo->unionid) ? $userinfo->unionid : '';
$data = array('openid' => $result->openid, 'unionid' => $userinfo->unionid, 'nickname' => $userinfo->nickname, 'sex' => $userinfo->sex, 'province' => $userinfo->province, 'city' => $userinfo->city, 'headimgurl' => $userinfo->headimgurl);
$where = "openid='{$result->openid}' OR unionid={$userinfo->unionid}";
$user = M('User')->where($where)->find();
if (!empty($user)) {
M('User')->save($data);
}
header('Location: ' . 'http://' . $_SERVER['HTTP_HOST'] . '?nickname=' . $userinfo->nickname . '&openid=' . $result->openid . '&unionid=' . $unionid);
}
}
}
开发者ID:qinzhi,项目名称:taoj,代码行数:30,代码来源:PublicController.class.php
示例2: update_menu
/**
* 创建自定义菜单
*/
public function update_menu($menu_json)
{
$access_token = $this->get_access_token();
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token;
$res = http($url, $menu_json, 'post', array(), true);
return json_decode($res, true);
}
开发者ID:licaikai,项目名称:baby,代码行数:10,代码来源:FunctionModel.class.php
示例3: weixin
public function weixin()
{
$code = I('get.code');
//获取code
$get_access_token_url = 'https://api.weixin.qq.com/sns/oauth2/access_token';
$get_access_token_json = http($get_access_token_url, array('appid' => 'wx893a9906fda1ed2c', 'secret' => '0c3ff723b18f7767a5e34ecb876dc947', 'code' => $code, 'grant_type' => 'authorization_code'), get);
$access_token = json_decode($get_access_token_json, true)['access_token'];
//获取access_token
$openid = json_decode($get_access_token_json, true)['openid'];
$get_userinfo_url = 'https://api.weixin.qq.com/sns/userinfo';
$userinfo = http($get_userinfo_url, array('access_token' => $access_token, 'openid' => $openid), get);
$userinfo = json_decode($userinfo, true);
//获取用户信息
if ($userinfo['openid']) {
$check = M('Member')->where(array('openid' => $userinfo['openid']))->select();
if (!$check) {
$res = M('Member')->add(array('openid' => $userinfo['openid'], 'headimgurl' => $userinfo['headimgurl'], 'nickname' => $userinfo['nickname'], 'user' => $userinfo['openid'], 'registtime' => time(), 'last_login_time' => time()));
} else {
$res = M('Member')->where(array('openid' => $userinfo['openid']))->save(array('last_login_time' => time()));
}
if ($res) {
$data = array('user' => $userinfo['openid'], 'nickname' => $userinfo['nickname'], 'status' => 1, 'headimgurl' => $userinfo['headimgurl']);
cookie('login', json_encode($data), 604800);
}
}
$this->redirect('Admin/index');
}
开发者ID:licaikai,项目名称:baby,代码行数:27,代码来源:AdminController.class.php
示例4: call
/**
* call() makes a simple call to Asana's api
*
* @param $method string HTTP request method
* @param $path string The path requested, after the API endpoint
* @param $data array An array of data to be included in the request
*
* @return array [$code,$headers,$body]
*/
function call($method, $path, $data)
{
$endpoint = "https://app.asana.com/api/1.0";
$token = conf("token");
$data = count($data) ? "?" . http_build_query($data) : "";
list($code, $headers, $body) = http($method, "{$endpoint}/{$path}{$data}", null, "Authorization: Bearer {$token}");
return [$code, $headers, json_decode($body)];
}
开发者ID:myklv,项目名称:asana-lite,代码行数:17,代码来源:call.php
示例5: cornGetAccessToken
public function cornGetAccessToken()
{
$appID = C('WEIXIN_BASE.APP_ID');
$appSecret = C('WEIXIN_BASE.APP_SECRET');
$tokenGet = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appID . '&secret=' . $appSecret;
$res = json_decode(http($tokenGet, '', 'get', true), true);
$this->cache->set('ACCESS_TOKEN', $res['access_token'], $res['expires_in']);
}
开发者ID:devsnippet,项目名称:wechatApp,代码行数:8,代码来源:IndexController.class.php
示例6: getAccessToken
function getAccessToken($server, $requestUrl, $consumer_key, $oauth_verifier, $oauth_token) {
$oauth_token_secret = $_SESSION['oauth_token_secret'];
$timeStamp = time();
$url = $server.$requestUrl."?oauth_consumer_key=".$consumer_key;
$url .= "&oauth_signature_method=PLAINTEXT&oauth_nonce=99806503068046&oauth_version=1.0&oauth_timestamp=";
$url .= $timeStamp."&oauth_verifier=".$oauth_verifier."&oauth_token=".$oauth_token."&oauth_signature=%26".$oauth_token_secret;
$r = http($url);
return oAuthParseResponse($r);
}
开发者ID:redbugz,项目名称:family-analysis,代码行数:9,代码来源:oauth.php
示例7: send
public function send($route)
{
if (http()->is_ajax()) {
return ['send' => $this->make($route)];
}
@ob_clean();
header('Location: ' . $this->make($route));
exit;
}
开发者ID:moxi9,项目名称:unity,代码行数:9,代码来源:Url.php
示例8: customMenuListCreate
public function customMenuListCreate()
{
$url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $this->token;
$btn['button'] = array(array('type' => 'click', 'name' => 'click事件', 'key' => 'clickEvent'), array('type' => 'view', 'name' => 'url跳转事件', 'url' => 'http://www.baidu.com'), array('name' => '子菜单', 'sub_button' => array(array('type' => 'view', 'name' => 'url跳转事件', 'url' => 'http://www.baidu.com'), array('type' => 'click', 'name' => 'click事件', 'key' => 'subClickEvent'))));
$chStr = chineseStringSave($btn);
// json保存中文
$res = http($url, $chStr, 'post', true);
dump($res);
}
开发者ID:devsnippet,项目名称:wechatApp,代码行数:9,代码来源:CustomMenuListController.class.php
示例9: userInfoGet
private function userInfoGet($openIDArr)
{
$url = 'https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token=' . $this->token;
foreach ($openIDArr['data']['openid'] as $v) {
// 遍历openid数组到查询条件数组
$data['user_list'][] = array('openid' => $v, 'lang' => 'zh-CN');
}
$res = json_decode(http($url, json_encode($data), 'post', true), true);
return $res;
}
开发者ID:devsnippet,项目名称:wechatApp,代码行数:10,代码来源:UserInfoGetController.class.php
示例10: verify
function verify($continueUrl, $response)
{
$q = array('userIp' => $_SERVER['REMOTE_ADDR']);
$q['requestUri'] = $continueUrl;
$q['postBody'] = $response;
$q = http('POST', 'https://www.googleapis.com/identitytoolkit/v1/relyingparty/verifyAssertion?key=' . GAPIKEY, json_encode($q));
if ($q->status == 200) {
return json_decode($q->body, true);
}
return array();
}
开发者ID:sgml,项目名称:rww.io,代码行数:11,代码来源:rp_callback.php
示例11: get_user_info
/**
* 获取授权后的微信用户信息
*
* @param string $access_token
* @param string $open_id
*/
public function get_user_info($access_token = '', $open_id = '')
{
if ($access_token && $open_id) {
$info_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$access_token}&openid={$open_id}&lang=zh_CN";
$info_data = http($info_url);
if ($info_data[0] == 200) {
return json_decode($info_data[1], TRUE);
}
}
return FALSE;
}
开发者ID:836806981,项目名称:TLAY,代码行数:17,代码来源:Wechat.class.php
示例12: trigger_scraper
function trigger_scraper($user, $persona_id)
{
global $scoop_ui_url;
// should be defined in local_config.php
if (!isset($scoop_ui_url)) {
$scoop_ui_url = "http://localhost:7070";
}
$params = array('userName' => $user->login_name, 'password' => $user->password, 'pwtype' => 'md5');
$params['todo'] = $persona_id . ',';
// http://localhost:7070/sessionStart?userName=userName&password=xxxxx
// we would like to do POST
$retun = http('POST', $scoop_ui_url . '/sessionStart', $params);
// echo "<hr>$return<hr>"; // debug!!
}
开发者ID:Cyberspace-Networks,项目名称:PeopleAggregator,代码行数:14,代码来源:refreshpersona.php
示例13: mainfunc
function mainfunc($posts, $debug = false)
{
$ip = $_SERVER["REMOTE_ADDR"];
@($token = $_COOKIE['token']);
$url = "http://127.0.0.1/api/jiekouapi.php?ip={$ip}&token={$token}";
if ($debug) {
$url = $url . "&debug=yes";
}
$rawstr = http($url, "POST", $posts);
if ($debug) {
return $rawstr;
}
@($xml = simplexml_load_string($rawstr, null, LIBXML_NOCDATA));
return json_decode(json_encode($xml->xpath("info")), true);
}
开发者ID:hun-tun,项目名称:CAPUBBS,代码行数:15,代码来源:mainfunc.php
示例14: ifrget
function ifrget($a, $b, $f)
{
$f = ajxg($f);
$f = http($f);
if ($f) {
$ret = curl_get_contents($f);
if (is_image($f) && $ret) {
$ret = ifrim($f, $ret);
}
}
$encoding = embed_detect(strtolower($ret), "charset=", '"', "");
if (strtolower($encoding) == "utf-8" or strpos($ret, 'é')) {
$ret = utf8_decode_b($ret);
}
return $ret;
}
开发者ID:philum,项目名称:cms,代码行数:16,代码来源:ifr.php
示例15: render
public function render($callback = null)
{
try {
$render = new Route\Render($this->_app);
$response = $render->execute();
} catch (Exception\Fatal $e) {
d($e->getTraceAsString());
exit('fatal: ' . $e->getMessage());
} catch (Exception $e) {
$response = $e->getMessage();
if (app()->http->is_ajax()) {
http_response_code(400);
$response = ['error' => $e->getMessageArray()];
} else {
if ($handler = config('error_handler')) {
$response = call_user_func($handler, $e);
}
}
}
$uri = request()->uri();
if (is_object($response) || is_array($response)) {
http()->type('json');
} else {
if (substr($uri, -3) == '.js') {
http()->type('js');
$url = url($uri);
echo 'Unity.blocklet(\'' . $url . '\', ' . json_encode(['view' => $response]) . ');';
exit;
} else {
if ($response === false) {
http()->type('404');
$response = 'Page not found.';
} else {
http()->type('html');
}
/*
if ($response === null || app()->http->is_ajax()) {
exit;
}
*/
}
}
if (is_callable($callback)) {
return call_user_func($callback, $response);
}
return $response;
}
开发者ID:moxi9,项目名称:unity,代码行数:47,代码来源:Site.php
示例16: templateMessageSend
public function templateMessageSend()
{
$token = $this->token;
$url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $token;
$temp['touser'] = 'oISyswgLg57fmt6M0K_gISej63HY';
$temp['template_id'] = '2fEe_qquorTi5z1Vau2-QU8kaL8XUka_BZuXg45JMVQ';
// 模板ID
$temp['url'] = 'http://www.baidu.com';
// 当用户点击模板消息后跳转过去的链接
$temp['data'] = array('name' => array('value' => 'Mr.Z', 'color' => '#173177'), 'time' => array('value' => date('Y-m-d H:i:s', time()), 'color' => '#173177'));
array_walk_recursive($temp, function (&$v) {
$v = urlencode($v);
});
$tempData = urldecode(json_encode($temp));
$res = json_decode(http($url, $tempData, 'post', true), true);
dump($res);
}
开发者ID:ZXCDFGTYU,项目名称:wechatApp,代码行数:17,代码来源:MessageSendController.class.php
示例17: get_weather
function get_weather()
{
if (getenv("HTTP_CLIENT_IP")) {
$ip = getenv("HTTP_CLIENT_IP");
} else {
if (getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
} else {
if (getenv("REMOTE_ADDR")) {
$ip = getenv("REMOTE_ADDR");
}
}
}
$ip = '175.10.239.240';
$httpstr = http('http://api.36wu.com/Weather/GetWeatherByIp', array('ip' => $ip), 'get');
return json_decode($httpstr);
}
开发者ID:qinzhi,项目名称:taoj,代码行数:17,代码来源:WeatherApi.class.php
示例18: tempResourceCreate
public function tempResourceCreate()
{
// $url = 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' . $this->token . '&type=image';
// $file = array(
// 'filename' => '/ace/app/webroot/Public/Weixin/img/doge.jpg',
// 'content-type' => 'image/jpeg',
// 'filelength' => '8488',
// );
dump($_SERVER);
exit;
// $data = array(
// 'media' => '/ace/app/webroot/Public/Weixin/img/doge.jpg',
// 'form-data' => $file,
// );
$res = json_decode(http($url, json_encode($data), 'post', true), true);
dump($res);
}
开发者ID:devsnippet,项目名称:wechatApp,代码行数:17,代码来源:ResourceManagerController.class.php
示例19: access_token
public function access_token($appid, $code, &$i = 0)
{
$appsecret = $this->model_config->val("appsecret");
$appsecret = trim($appsecret);
$appid = trim($appid);
$url = "https://api.weixin.qq.com/sns/oauth2/access_token";
$param = array("appid" => $appid, "secret" => $appsecret, "code" => $code, "grant_type" => "authorization_code");
$httpstr = http($url, $param);
$harr = json_decode($httpstr, true);
if (empty($harr['access_token'])) {
if ($i > 5) {
E("获取access_token失败");
}
$i++;
$this->access_token($appid, $code, $i);
}
$this->openid = $harr['openid'];
}
开发者ID:noikiy,项目名称:luokeke2,代码行数:18,代码来源:HongBaoController.class.php
示例20: getRaw
public static function getRaw($action, $ref, $data, $method = "POST")
{
/*self::action =$action;//"http://202.115.71.131/iv/queryPastPro.do?url=In";
$method ="POST";
$ref = "http://202.115.71.131/iv/queryPastPro.do?url=In";
$data = ['name'=>'张逊桥',
'btn'=>'执行查询',
'qishuId'=>'',//5,
'srtpProject.projCollege'=>'信息科学与技术学院'
];*/
//import('LIB.LIB_http.php');
//require_once('../../LIB/LIB_http.php');
$response = http($target = $action, $ref, $method, $data, EXCL_HEAD);
return $response;
//输入项目名 或者 参与人员 的学号 或您的 姓名 或指 导教师姓名
//"/iv/queryPastPro.do?url=In"
//name srtpProject.projCollege qishuId
//name=&srtpProject.projCollege=%E4%BF%A1%E6%81%AF%E7%A7%91%E5%AD%A6%E4%B8%8E%E6%8A%80%E6%9C%AF%E5%AD%A6%E9%99%A2&qishuId=5&btn=%E6%89%A7%E8%A1%8C%E6%9F%A5%E8%AF%A2
}
开发者ID:XQ-quadrant,项目名称:gbCMS,代码行数:19,代码来源:SearchModel.class.php
注:本文中的http函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论