### 配置
1. appid
2. appsecret
3. merchid
4. apikey
5. 微信公众号,接口权限,网页授权域名填写
### 获取code
```
function getWxCode($url){
$appid = "";
$appsecret = "";
$domain = input('server.REQUEST_SCHEME'). '://' . input('server.SERVER_NAME');
//url填写可当前访问url
$redirect_url = $domain."/".$url;
$redirect_url = urlencode($redirect_url);
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_url."&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
// dump($url);exit;
// $result = curl_get($url);
// return $result;
return $url;
}
//引导用户访问此url
```
### 根据code获取openid
```
$param =request()->param();
$code = $param['code'];
function returnAsskey($code)
{
$appid = “”;
$appsec
微信浏览器网页授权获取用户openid 微信浏览器支付
最新推荐文章于 2024-06-23 23:51:42 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)