Beispiel #1
0
function getUserInfo($oauth2URL)
{
    $userInfo = session('userInfo');
    if ($userInfo) {
        return $userInfo;
    }
    $userInfo = getSubscribe($oauth2URL);
    session('userInfo', $userInfo);
    return $userInfo;
}
Beispiel #2
0
$payurl = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers';
//企业付款接口请求URL
$openid = $_SESSION['wx_user']['openid'];
$username = $_SESSION['wx_user']['nickname'];
$headimgurl = $_SESSION['wx_user']['headimgurl'];
$jssdk = new JSSDK($appid, $appsecret);
$signPackage = $jssdk->GetSignPackage();
$time = time();
/* 1块到1块五(单位分) */
$rands = [1, 1.01, 1.02, 1.03, 1.04, 1.05, 1.06, 1.07, 1.08, 1.09, 1.1, 1.11, 1.12, 1.13, 1.14, 1.15, 1.16, 1.17, 1.18, 1.19, 1.2];
/* 砸蛋动态 */
$sql = "SELECT username,headimgurl,money,addtime FROM m_beat_egg_logs ORDER BY id DESC LIMIT 8";
$sth = $db->prepare($sql);
$sth->execute();
$lists = $sth->fetchAll(PDO::FETCH_ASSOC);
$uInfo = getSubscribe($appid, $appsecret, $openid);
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);
}
function https_request($url)
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);