? ??? ??? ??? WeChat ?? ??? ?? ???? ??? ?? ???? ???? ?? ??? ???? ??? ??? ??? ?? ?????? WeChat ??? ???? ??? ??? ?? ???????. WeChat ?? ?? ?? ? ???? ??? ??? ??? ? ????
??? ?? ?? ????? ??? ???? ?? ? ??? ?? ?? ???? ?????? ???? ? ?????.
? ??? ??? ?????? ?? ??? ???? ????? ???? ???? ???? ????. ?????? ?? ???
(? ?? ?? ??? ??? ???? ????. ? ?? ??? PHP ? ?? ??? ?????)
//自定義請求接口函數(shù),$data為空時(shí)發(fā)起get請求,$data有值時(shí)發(fā)情post請求 function http_url($url,$data=null){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); if(!empty($data)){ curl_setopt($ch,CURLOPT_POST,1); curl_setopt($ch,CURLOPT_POSTFIELDS,$data); } $res = curl_exec($ch); if(curl_errno($ch)){ echo "error:".curl_error($ch); exit; } curl_close($ch); return $res; }
(?? ???? ????? ? ??? Tencent?? ????? ??? ????. WeChat ?? ???? ??? ??)
? ?????. 1. ?? ?? ??? ???? ???
1. WeChat ?? ??? ??? ? ??? ??? ???? ?? ???? ?? ???? ?? ?????? "?? - ????? ?? - ? ??? - ? ?? - ?? ??? ??? ?? ?? ? ??" ?? ???? ???? ???. ?? ?? ??? ??? ?????. ???? URL? ?? ??? ??(???)? ????? http://? ?? ???? ??? ???? ???.
2 ?? ?? ??? ?? ?? ??? ??? ????. ?? ??? ??(?: ???? ??? ???) ??? ??? www.qq.com???. ?? ? ? ??? ?? ??? ???? http://www.qq.com/music.html ? http://???. OAuth2.0 ???? www.qq.com/login.html? ??? ? ????. ?, http://pay.qq.com, http://music.qq.com, http://qq.com? OAuth2.0 ??? ??? ? ????3. ?? ?? ???? ?3??? ??? ??. ??? ??? ?? ?? ??? ? ??? ????. ?3?? ?? ??? ???? ? ??? ??? ??? ? ????2. ???? ??? ???? ???? ? ?????
????? ??:https://open.weixin.qq .com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect (????? ????? ?????)
function Get_Code() //獲取code { //構(gòu)造請求地址 $code_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=微信公眾號appid&redirect_uri=請求功后回調(diào)地址&response_type=code&scope=snsapi_userinfo&state=STATE #wechat_redirect"; //跳轉(zhuǎn)到請求地址,應(yīng)為本省設(shè)置了回調(diào)地址,所以不需要使用file_get_content()來請求接口。 header("location:" . $code_url); exit; }
3. ??? ??? access_token ? openid
?????: https://api.weixin.qq.com/sns/auth?access_token=ACCESS_TOKEN&openid=OPENID
/** * 通過獲取到的code來獲取access_token和openid * $code為獲取到的code * 接口的參數(shù)注意換成自己的,如appid和secret */ function GetAccess_Token($code) { $get_access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=appid&secret=secret&code=$code&grant_type=authorization_code"; $res = http_url($get_access_token_url); return json_decode($res, true); }
https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN
/** * 檢查access_token是否有效 * */ function CkeckAccessToken($access_token, $openid) { $check_url = "https://api.weixin.qq.com/sns/auth?access_token=$access_token&openid=$openid"; $res = http_url($check_url); $result = json_decode($res, true); if (isset($result['errmsg']) && $result['errmsg'] == 1) { return 1; //access_token有效 } else { return 0; //access_token無效 } }
?????:
獲取到用戶信息數(shù)據(jù):/** * 獲取用戶基本信息 * */
function Get_User_Info($access_token, $openid){
$get_user_info = "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid&lang=zh_CN";
$res = http_url($get_user_info);
return json_decode($res, true);
}
{
"openid":" OPENID",
" nickname": NICKNAME,
"sex":"1",
"province":"PROVINCE"
"city":"CITY",
"country":"COUNTRY",
"headimgurl": "http://thirdwx.qlogo.cn/mmopen/g3MonUZtNHkdmzicIlibx6iaFqAc56vxLSUfpb6n5WKSYVY0ChQKkiaJSgQ1dZuTOgvLLrhJbERQQ4eMsv84eavHiaiceqxibJxCfHe/46",
"privilege":[ "PRIVILEGE1" "PRIVILEGE2" ],
"unionid": "o6_bmasdasdsad6_2sgVt7hMZOPfL"
}
下面上完整代碼:
<?php
//跳轉(zhuǎn)第三方頁面,獲取用戶基本信息
// 這是請求頁面也是code的回調(diào)頁面
session_start(); //啟動session
if (isset($_GET['code'])) { //判斷是否有code傳過來,如果沒有調(diào)用函數(shù)請求code
$res = GetAccess_Token($_GET['code']); //使用code獲取access_token和openid
if (CkeckAccessToken($res['access_token'], $res['openid']) == 0) { //判斷access_token是否有效,如果無效獲取新的access_token
$res = GetRefresh_Token($res['refresh_token']); //或缺新的access_token
}
$userinfo = Get_User_Info($res['access_token'], $res['openid']); //獲取用戶信息
$_SESSION['userinfo'] = $userinfo; //將用戶信息存入session中
$next_url = 'http://web/index.php'; //下一個(gè)頁面地址
header("location:" . $next_url); //獲取到信息后跳轉(zhuǎn)到其他頁面
exit;
} else {
//獲取code
Get_Code();
}
function Get_Code() //獲取code{
$code_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=appid&redirect_uri=回調(diào)地址&response_type=code&scope=snsapi_userinfo&state=STATE #wechat_redirect";
header("location:" . $code_url);
exit;
}
/**
* 通過獲取到的code來獲取access_token和openid
*
*/
function GetAccess_Token($code){
$get_access_token_url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=appid&secret=secret&code=$code&grant_type=authorization_code";
$res = http_url($get_access_token_url);
return json_decode($res, true);
}
/**
* 檢查access_token是否有效
*
*/
function CkeckAccessToken($access_token, $openid){
$check_url = "https://api.weixin.qq.com/sns/auth?access_token=$access_token&openid=$openid";
$res = http_url($check_url);
$result = json_decode($res, true);
if (isset($result['errmsg']) && $result['errmsg'] == 1) {
return 1; //access_token有效
} else {
return 0; //access_token無效
}
}
/**
* 如果獲取到的access_token無效,通過refresh_token來刷新access_token
*/
function GetRefresh_Token($refresh_token){
$get_refresh_token_url = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=appid&grant_type=refresh_token&refresh_token=$refresh_token";
$res = http_url($get_refresh_token_url);
return json_decode($res, true);
}
/**
* 獲取用戶基本信息
*
*/
function Get_User_Info($access_token, $openid){
$get_user_info = "https://api.weixin.qq.com/sns/userinfo?access_token=$access_token&openid=$openid&lang=zh_CN";
$res = http_url($get_user_info);
return json_decode($res, true);}
//自定義請求接口函數(shù),$data為空時(shí)發(fā)起get請求,$data有值時(shí)發(fā)起post請求
function http_url($url,$data=null){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
if(!empty($data)){
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
}
$res = curl_exec($ch);
if(curl_errno($ch)){
echo "error:".curl_error($ch);
exit;
}
curl_close($ch);
return $res;
}
? ?
? ??? WeChat ?? ?? ? ??? ?? ??? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

Douyin ? ??? ??? ??? https://www.douyin.com/???. ??? ???? ??? ?????. 1. ???? ??; 2. URL https://www.douyin.com/? ??????. 3. "???"??? ???? ??? ??? ??????. 4. ?? ????? ??????. 5. ?? ???. ? ??? ????, ??, ?? ??, ??? ??? ? ?? ???? ??? ?? ??? ???? ?? ??? ??, ?? ???, ??? ?? ?? ? ??? ??? ?? ??? ????.

??? ???? ?? ?? ? ???? ?? ????? ?????. ???? ????? ????? ?? ????? ???? ???? ? ?? ???? ????? ??? ???? ?? ??? ?? ? ????. ???? ????? ??? ??? ???? ??? ???? ??? ???? ? ????. Copy Comics?? ???? ?? ??? ?? ??? ?? ?? ??? ?? ??? ?? ?? ?????, ???? ???? ?? ??? ???, ???? ?? ??? ???? ??? ?? ??? ??? ? ????.

UC ???? ?? QQ ????? ???? ?? ??? ?? ????. 1. UC ????? ???? ? ??? ?????? ??? ???? ????? ?????. 2. QQ ????? Tencent ???? ???? ??? ??? ??? ????? ?????.

2025 ? ?? ?? ???? ??? ?? ???? ??? ??? ?? ??? ? ??? ???? ????? ?? ??, ?? ?? ? ?? ???? ?? ?? ????? ??? ?? 10 ?? ??? ? AI ?? ????? ?? ?????.

?? ???? ?? ?? ?? ?? ? ?? ?? ??? ? Nice Comics? ????? ?? ??? ?? ??? ?????. ?? ?? ??? ?? ? ??? ?? ???? ??? ???? ?? ??? ???? ??????????. ???? ??? ? ????? ???? ??? ?? ??? ?? NES Comics? ???? ???? ??? ?? ?? ? ??? ???? ??? ?? ??? ?? ? ????. ???? ???? ???? ??? ??? ?? ?????, ?? ??? ??? ?? ???? ?? ??? ??????!

Frogman Comics? ???? ??? ?? ??? ???? ??? ??? ?? ??? ?? ?? ?? ?????? ? ?? ????????. ??? ???? ???? ???? ???? ???? ??? ???? ????? ???? ??? ??? ????. ??? ?? ??? ??? ? ???? ??? ??, ??? ? ?? ???? ???? ??? ????? ??? ??? ??? ????. ?? ??? ???? ???? ?? ???? ??? ?? ? ????. ???? ??? ? ????? ???? ?? ?? ???? ?? ?? ??? ??? ?? ?? ??? ?? ??? ?? ? ? ????.

???, ??? ??? ? ?? ???? ???? ???? ?? ??, ????? ??? ?? ???? ???? ???? ???? ?? ??? ????? ??? ??? ???? ?? ? ??? ??? ??? ??? ???? ??? ?? ? ? ????. ??? ?? ??? ?? ??? ??????? ??? ?? ??? ????? ???? ?????? ??? ? ?? ???? ??? ?? ? ??? ???????.

2025b Anhui? ?? ?? ? ???? ??? ????. https://www.marketwebb.co/zh-cn/join?ref=507720986&type=wenzi; Binance Exchange? ??, ??, ??, ??, ?? ? ????? ? 180 ??? ??? ???? ???? ??? ?? ?? ??????. 600 ?? ?? ?? ??? ???? ? ????? 2 ? 7 ?? ?? ?? ? ???? ???? ????.
