wudaosoft-weixin-sdk

Wudaosoft Weixin SDK

License

License

GroupId

GroupId

com.wudaosoft
ArtifactId

ArtifactId

wudaosoft-weixin-sdk
Last Version

Last Version

3.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

wudaosoft-weixin-sdk
Wudaosoft Weixin SDK
Project URL

Project URL

http://www.wudaosoft.com
Project Organization

Project Organization

Wudao Software Studio
Source Code Management

Source Code Management

https://github.com/changsoul/wudaosoft-weixin-sdk

Download wudaosoft-weixin-sdk

How to add to project

<!-- https://jarcasting.com/artifacts/com.wudaosoft/wudaosoft-weixin-sdk/ -->
<dependency>
    <groupId>com.wudaosoft</groupId>
    <artifactId>wudaosoft-weixin-sdk</artifactId>
    <version>3.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.wudaosoft/wudaosoft-weixin-sdk/
implementation 'com.wudaosoft:wudaosoft-weixin-sdk:3.0.3'
// https://jarcasting.com/artifacts/com.wudaosoft/wudaosoft-weixin-sdk/
implementation ("com.wudaosoft:wudaosoft-weixin-sdk:3.0.3")
'com.wudaosoft:wudaosoft-weixin-sdk:jar:3.0.3'
<dependency org="com.wudaosoft" name="wudaosoft-weixin-sdk" rev="3.0.3">
  <artifact name="wudaosoft-weixin-sdk" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.wudaosoft', module='wudaosoft-weixin-sdk', version='3.0.3')
)
libraryDependencies += "com.wudaosoft" % "wudaosoft-weixin-sdk" % "3.0.3"
[com.wudaosoft/wudaosoft-weixin-sdk "3.0.3"]

Dependencies

compile (2)

Group / Artifact Type Version
commons-codec : commons-codec jar 1.13
com.wudaosoft : wudaosoft-httpclient jar 2.0.6

provided (7)

Group / Artifact Type Version
org.springframework : spring-webmvc jar 5.2.5.RELEASE
javax.servlet : javax.servlet-api jar 4.0.1
org.slf4j : jcl-over-slf4j jar 1.7.30
org.slf4j : log4j-over-slf4j jar 1.7.30
org.slf4j : jul-to-slf4j jar 1.7.30
org.slf4j : slf4j-api jar 1.7.30
ch.qos.logback : logback-classic jar 1.2.3

Project Modules

There are no modules declared in this project.

wudaosoft-weixin-sdk

Maven Central License

Wudaosoft Weixin Official SDK.

Download

Maven

<dependency>
    <groupId>com.wudaosoft</groupId>
    <artifactId>wudaosoft-weixin-sdk</artifactId>
    <version>3.0.3</version>
</dependency>

Gradle/Grails

compile 'com.wudaosoft:wudaosoft-weixin-sdk:3.0.3'

Getting started

You need to add the @EnableWeiXinOfficial annotation to one of your @Configuration classes, the Weixin Official API be enabled.

package com.example.myproject;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.wudaosoft.weixinsdk.annotation.EnableWeiXinOfficial;
import com.wudaosoft.weixinsdk.config.WeiXinConfig;

@Configuration
@EnableWeiXinOfficial
public class Application {

	@Bean
	public WeiXinConfig weiXinConfig() {
		return new WeiXinConfig("appid", "appsecret");
	}
	
	// ...

}

Now, you can use the Weixin Official APIs.

For example, to get OAuth2 Userinfo data would be:

package com.example.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wudaosoft.weixinsdk.oauth2.OAuth2AccessToken;
import com.wudaosoft.weixinsdk.oauth2.OAuth2Api;
import com.wudaosoft.weixinsdk.oauth2.OAuth2UserInfo;

@Service
public class WeixinService {

	@Autowired
	private OAuth2Api oauth2Api;

	public void doAuth(String code, String state) {
		OAuth2AccessToken authToken = oauth2Api.getOauth2AccessToken(code);
    	
    		if (authToken.getErrcode() != 0) {
    			// throw an exception
    		}
    	
    		OAuth2UserInfo userInfo = oauth2Api.oauth2UserInfo(authToken.getAccess_token(), authToken.getOpenid(), "zh_CN");
    	
    		if (userInfo.getErrcode() != 0) {
    			// throw an exception
    		}
    	
    		System.out.println(String.format("nickname: %s", userInfo.getNickname()));
    	
    		// do something you want ...
	}

	// ...

}

Here are APIs list:

  • ArticlesApi
  • CustomMsgSender
  • MaterialApi
  • MenuApi
  • OAuth2Api
  • QRCodeApi
  • UserApi
  • UserGroupApi
  • CommonApi for static way
  • ResponseMsgBuilder for static way

License

wudaosoft-weixin-sdk is released under the Apache 2.0 license.

Copyright 2009-2018 Wudao Software Studio

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Versions

Version
3.0.3
3.0.2
3.0.1
3.0.0
2.0.4
2.0.3
2.0.2
2.0.1
2.0.0
1.0.0