本文整理汇总了PHP中https_request函数的典型用法代码示例。如果您正苦于以下问题:PHP https_request函数的具体用法?PHP https_request怎么用?PHP https_request使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了https_request函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getaccesstoken
function getaccesstoken($appid, $appsecret) {
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$appsecret;
$result = https_request($url);
$jsoninfo = json_decode($result, true);
$access_token = $jsoninfo["access_token"];
return $access_token;
}
示例2: test
public function test()
{
$url = __ROOT__ . '/getWxInfo.php';
$arr = https_request($url);
p($arr);
die;
}
示例3: ip
public function ip()
{
$ip = $this->input->get('ip', TRUE);
$result = https_request("http://ipapi.sinaapp.com/api.php?f=json&ip={$ip}");
$data = json_decode($result, true);
echo $data['area1'];
}
示例4: get_token
function get_token()
{
$appid = "wx8f0a915f08327903";
$appsecret = "d4624c36b6795d1d99dcf0547af5443d";
$curl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$tokendata = https_request($curl);
$arrtoken = json_decode($tokendata, true);
return $arrtoken["access_token"];
}
示例5: getJsApiTicket
function getJsApiTicket($accessToken)
{
// jsapi_ticket 应该全局存储与更新,以下代码以写入到文件中做示例
$data = json_decode(file_get_contents("jsapi_ticket.json"));
if ($data->expire_time < time()) {
// 如果是企业号用以下 URL 获取 ticket
// $url = "https://qyapi.weixin.qq.com/cgi-bin/get_jsapi_ticket?access_token=$accessToken";
$url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=" . $accessToken;
$res = json_decode(https_request($url));
$ticket = $res->ticket;
if ($ticket) {
$data->expire_time = time() + 7000;
$data->jsapi_ticket = $ticket;
$fp = fopen("jsapi_ticket.json", "w");
fwrite($fp, json_encode($data));
fclose($fp);
}
} else {
$ticket = $data->jsapi_ticket;
}
return $ticket;
}
示例6: getSubscribe
function getSubscribe($appid, $appsecret, $openid)
{
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$accessToken = https_request($url);
$accessToken = json_decode($accessToken, true);
$token = $accessToken['access_token'];
$dingyue_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$token}&openid={$openid}&lang=zh_CN";
$dingyue_json = https_request($dingyue_url);
return json_decode($dingyue_json, true);
}
示例7: getwuserinfo
function getwuserinfo($postObj, $appid, $appsecret)
{
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$result = https_request($url);
$jsoninfo = json_decode($result, true);
$access_token = $jsoninfo["access_token"];
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $postObj->FromUserName . "&lang=zh_CN";
$wuser = https_request($url);
$wuser = json_decode($wuser, true);
return $wuser;
}
示例8: get_userinfo
function get_userinfo($code, $cfg)
{
//====获取access_token
$access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $cfg['appid'] . "&secret=" . $cfg['appsecret'] . "&code=" . $code . "&grant_type=authorization_code";
$access_token_result = https_request($access_token_url);
$access_token_arr = json_decode($access_token_result, true);
//====获取用户信息
$userinfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token_arr['access_token'] . "&openid=" . $access_token_arr['openid'];
$userinfo_result = https_request($userinfo_url);
$userinfo_arr = json_decode($userinfo_result, true);
return $userinfo_arr;
}
示例9: url2arr
function url2arr($url, $json)
{
if (C('psnvs') != 1) {
$json = https_request($url);
}
$arr = json_decode($json, true);
if ($arr['code'] != 'A00000') {
logger('#', 'log/log_' . date('Y-m-d', time()) . '.txt');
logger('url: ' . $url, 'log/log_' . date('Y-m-d', time()) . '.txt');
logger('json: ' . $json, 'log/log_' . date('Y-m-d', time()) . '.txt');
}
$arr['url'] = $url;
return $arr;
}
示例10: getUserInfo
function getUserInfo($code)
{
$appid = "wx112a5b680de6941e";
$appsecret = "bc85e6bec70db896784884ec28151598";
//获取access token和openid https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code
$new_access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code";
$new_access_token_json = https_request($new_access_token_url);
$new_access_token_array = json_decode($new_access_token_json, true);
$new_access_token = $new_access_token_array['access_token'];
//全局access token获得用户基本信息https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN
$userinfo_url = "https://api.weixin.qq.com/sns/userinfo?access_token={$new_access_token}&openid={$openid}&lang=zh_CN";
$userinfo_json = https_request($userinfo_url);
$userinfo_array = json_decode($userinfo_json, true);
return $userinfo_array;
}
示例11: getUserInfo
function getUserInfo($code)
{
$appid = "wx0fed524d0dbafd1e";
$appsecret = "b3fca70bef3775f844f3597bb09a2e9d";
// oauth2的方式获得openid
$access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code";
$access_token_json = https_request($access_token_url);
$access_token_array = json_decode($access_token_json, true);
$openid = $access_token_array['openid'];
// 非oauth2的方式获得全局access token
$new_access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$new_access_token_json = https_request($new_access_token_url);
$new_access_token_array = json_decode($new_access_token_json, true);
$new_access_token = $new_access_token_array['access_token'];
// 全局access token获得用户基本信息
$userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$new_access_token}&openid={$openid}";
$userinfo_json = https_request($userinfo_url);
$userinfo_array = json_decode($userinfo_json, true);
return $userinfo_array;
}
示例12: getUserInfo
function getUserInfo($code, $appid, $appsecret)
{
// $appid = "wx08c69e5ad5cc1a5e";
// $appsecret = "95c2d97c3557a65b5f6f7e962b363256";
//oauth2的方式获得openid
$access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$appid}&secret={$appsecret}&code={$code}&grant_type=authorization_code";
$access_token_json = https_request($access_token_url);
$access_token_array = json_decode($access_token_json, true);
$openid = $access_token_array['openid'];
//非oauth2的方式获得全局access token
$new_access_token_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$appsecret}";
$new_access_token_json = https_request($new_access_token_url);
$new_access_token_array = json_decode($new_access_token_json, true);
$new_access_token = $new_access_token_array['access_token'];
//全局access token获得用户基本信息
$userinfo_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={$new_access_token}&openid={$openid}";
$userinfo_json = https_request($userinfo_url);
$userinfo_array = json_decode($userinfo_json, true);
return $userinfo_array;
}
示例13: getTicket
function getTicket($access_token, $tempewm)
{
$data = json_decode(file_get_contents("jsapi_ticket.json"));
if ($data->expire_time < time()) {
// 如果是企业号用以下URL获取access_token
// $url = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$this->appId&corpsecret=$this->appSecret";
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $access_token;
$res = json_decode(https_request($url, $tempewm));
$jsapi_ticket = $res->ticket;
if ($jsapi_ticket) {
$data->expire_time = time() + 7000;
$data->jsapi_ticket = $jsapi_ticket;
$fp = fopen("jsapi_ticket.json", "w");
fwrite($fp, json_encode($data));
fclose($fp);
}
} else {
$jsapi_ticket = $data->jsapi_ticket;
}
return $jsapi_ticket;
}
示例14: https_request
{
"type":"view",
"name":"联系方式",
"url":"http://www.toptophr.com/company/index.php?id=' . $_GET['uid'] . '&tp=connection&style=wap"
},
{
"type":"view",
"name":"地理位置",
"url":"http://www.toptophr.com/company/index.php?id=' . $_GET['uid'] . '&tp=position&style=wap"
}]
}]
}';
$url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $access_token;
$result = https_request($url, $jsonmenu);
var_dump($result);
function https_request($url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
示例15: https_request
require_once '../utils/Access_Token.class.php';
//$access_tokenApiObj = new Access_TokenApi();
//$access_token = $access_tokenApiObj->getAccess_Token();
$access_token = 'L43i6Tzh7k32FhT915yIOKcDipQODRiqubUByIh0asFTnCzy0YYzb5QJbsghECWBCtpi56bxwHaSqHS0BDBwAsSuDAGXEbhxxCqLSvrzU3g';
$openid = "oGer5jnhIvxmzFKZEtGnrv_yzHBc";
$data = '{
"touser":"' . $openid . '",
"msgtype":"text",
"text":
{
"content":"Hello World"
}
}';
$url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=" . $access_token;
$result = https_request($url, $data);
var_dump($result);
function https_request($url, $data)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
if (curl_errno($curl)) {
return 'Errno' . curl_error($curl);
}
curl_close($curl);