Skip to content

Commit

Permalink
微信公众号菜单授权URL:增加state
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunfeng committed Oct 25, 2020
1 parent d010c7e commit a2c966d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>cn.buk.api.wechat</groupId>
<artifactId>weniu</artifactId>
<version>2.0.6-SNAPSHOT</version>
<version>2.0.7-SNAPSHOT</version>
<packaging>pom</packaging>

<name>weniu</name>
Expand Down
5 changes: 2 additions & 3 deletions weniu-dao/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.buk.api.wechat</groupId>
<artifactId>weniu</artifactId>
<version>2.0.6-SNAPSHOT</version>
<version>2.0.7-SNAPSHOT</version>
</parent>

<artifactId>weniu-dao</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion weniu-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>cn.buk.api.wechat</groupId>
<artifactId>weniu</artifactId>
<version>2.0.6-SNAPSHOT</version>
<version>2.0.7-SNAPSHOT</version>
</parent>

<name>weniu-service</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1124,12 +1124,19 @@ private String readInputXml(HttpServletRequest request) {

/**
* 将实际url和授权url绑定
* state: wxs_5
* wxs 标识weixin_service_no,微信服务号,后面的数字5标识该企业的enterpriseId
*/
public String buildUrlInWeixin(final int enterpriseId, String url0) {
String appId = getAppId(enterpriseId);
try {
return "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appId +
"&redirect_uri=" + URLEncoder.encode(url0, "UTF-8") + "&response_type=code&scope=snsapi_base&state=#wechat_redirect";
return "https://open.weixin.qq.com/connect/oauth2/authorize?appid="
+ appId
+ "&redirect_uri=" + URLEncoder.encode(url0, "UTF-8")
+ "&response_type=code"
+ "&scope=snsapi_base" +
"&state=" + "wxs_" + enterpriseId +
"#wechat_redirect";
} catch (UnsupportedEncodingException e) {
e.printStackTrace();

Expand Down

0 comments on commit a2c966d

Please sign in to comment.