Home > php教程 > php手册 > body text

WeChat public platform, WeChat web page authorization, redirect_uri parameter error, solution!

WBOY
Release: 2016-12-05 13:26:26
Original
2446 people have browsed it

An error occurred when authorizing the WeChat webpage just now! ! ! WeChat webpage authorization redirect_uri parameter is wrong!

微信网页授权redirect_uri 参数错误

When you encounter a problem, the first thing you should do is check the technical documentation of the official WeChat public platform.

WeChat webpage authorization

If the user accesses a third-party webpage in the WeChat client, the official account can obtain the user's basic information through the WeChat webpage authorization mechanism to implement business logic.

Instructions on web page authorization callback domain name

1. Before WeChat official account requests user web page authorization, developers need to go to the configuration options of "Development - Interface Permission - Web Service - Web Account - Web Authorization to Obtain User Basic Information" on the official website of the public platform to modify the authorization callback. domain name. Please note that the domain name (which is a string) is filled in here, instead of the URL, so please do not add protocol headers such as http://;

2. The authorization callback domain name configuration specification is the full domain name. For example, the domain name that requires web page authorization is: www.qq.com. After configuration, the pages under this domain name are http://www.qq.com/music.html and http:/ /www.qq.com/login.html can perform OAuth2.0 authentication. But http://pay.qq.com, http://music.qq.com, http://qq.com cannot perform OAuth2.0 authentication

3. If the official account login authorization is given to a third-party developer for management, there is no need to make any settings. The third party can replace the official account to implement web page authorization.

Check the web services authorized by WeChat.

Web account Web page authorization to obtain user basic information No upper limit Modification

Click Modify, go in and change http://www.xxxx.cn to www.xxxx.cn and there will be no redirect_uri parameter error!

Note: http://www.xxxx.cn can be safely monitored through web page authorization. We didn’t know there was a problem. Later, when the program executed the call, we found that the redirect_uri parameter was wrong. After checking the document, we came back and found that it turned out to be The error here.

//Get the user’s openid
function getBaseInfo(){
//1. Get the code
$appid="qq1813284q1q6q8888";//The appid here is fake for demonstration purposes
$redirect_uri=urlencode("http:// www.xxxx.cn/xxx.php/Index/getUserOpenId");//The address here needs http://
$url="https://open.weixin.qq.com/connect/oauth2/authorize?appid =".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_base&state=123#wechat_redirect";
header('location:'.$url);
}

function getUserOpenId(){
//2. Obtain the access_token authorized by the web page
$appid="qq1813284q1q6q8888";//The appid here is fake for demonstration
$appsecret="61qqqq36745987167q73bq1q2552 qq75";//The appsecret here is false For demonstration use
$code=$_GET['code'];
$url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid."&secret=". $appsecret."&code=".$code."&grant_type=authorization_code ";
//3. Pull the user's openid
$res = $this->http_curl($url,'get');

 var_dump($res);//Print to see the user’s openid

}

Another complaint, uploading pictures in the blog park is very troublesome. You need to upload them to the photo album first, and then fill in the URL address when inserting the picture. The screenshot inserted into the mobile phone will be huge, and you need to set the size separately. This user experience, I also drunk.

Did I do it incorrectly? Just used Blog Park for 2 days.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template