You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
zhishifufei_php/extend/service/WechatSubscribe.php

52 lines
1.8 KiB

<?php
// +----------------------------------------------------------------------
// | 天诚科技 [ 刘海东 17600099397赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2020 https://www.tczxkj.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 该系统并不是自由软件,未经许可不能去掉相关版权
// +----------------------------------------------------------------------
// | Author:甘肃天诚志信电子商务有限公司 刘海东 联系电话维系17600099397
// +----------------------------------------------------------------------
namespace service;
use basic\AuthBasic;
class WechatSubscribe extends AuthBasic
{
/**
* 基础访问接口
* @var string
*/
const API_OAUTH_GET = 'https://api.weixin.qq.com/sns/userinfo';
/**GET请求 获取用户信息
* @param $access_token
* @param $openId
* @param string $lang
* @return mixed
*/
public static function baseParseGet($access_token, $openId, $lang = 'zh_CN')
{
$url = self::API_OAUTH_GET . "?access_token=" . $access_token . "&openid=" . $openId . "&lang=" . $lang;
return json_decode((new WechatSubscribe)->curlGet($url), true);
}
protected function curlGet($url = '', $options = array())
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
if (!empty($options)) {
curl_setopt_array($ch, $options);
}
//https请求 不验证证书和host
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
}