or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

advanced-services.mdindex.mdmaterial-management.mdmenu-management.mdmessage-handling.mdservice-management.mdshopping-guide.mdtemplate-messaging.mduser-management.md
tile.json

tessl/maven-com-github-binarywang--weixin-java-mp

Comprehensive Java SDK for WeChat Official Account development with complete API coverage for user management, messaging, materials, menus, and WeChat platform features.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.github.binarywang/weixin-java-mp@4.7.x

To install, run

npx @tessl/cli install tessl/maven-com-github-binarywang--weixin-java-mp@4.7.0

index.mddocs/

WeChat Official Account Java SDK (weixin-java-mp)

Comprehensive Java SDK for WeChat Official Account development providing complete API coverage for user management, messaging, materials, menus, and all WeChat platform features.

Package Information

  • Package Name: weixin-java-mp
  • Package Type: Maven
  • Group ID: com.github.binarywang
  • Artifact ID: weixin-java-mp
  • Language: Java
  • Installation: Add to pom.xml:
    <dependency>
      <groupId>com.github.binarywang</groupId>
      <artifactId>weixin-java-mp</artifactId>
      <version>4.7.0</version>
    </dependency>

Core Imports

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import me.chanjar.weixin.common.error.WxErrorException;

Basic Usage

import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import me.chanjar.weixin.mp.bean.result.WxMpUser;

// Initialize configuration
WxMpDefaultConfigImpl config = new WxMpDefaultConfigImpl();
config.setAppId("your-app-id");
config.setSecret("your-app-secret");

// Create service instance
WxMpService wxService = new WxMpServiceImpl();
wxService.setWxMpConfigStorage(config);

// Use specific services
String accessToken = wxService.getAccessToken();
WxMpUser user = wxService.getUserService().userInfo("openid", "zh_CN");

Architecture

The WeChat Official Account Java SDK follows a modular service-oriented architecture:

Core Components

  • WxMpService: Main service interface providing access to all functionality
  • WxMpConfigStorage: Configuration management for app credentials and tokens
  • Service Interfaces: 30+ specialized service interfaces for different WeChat features
  • Message Framework: Complete message handling, routing, and response building system
  • Bean Classes: Comprehensive data models for all WeChat API requests and responses

HTTP Client Support

The SDK supports multiple HTTP client implementations:

  • Apache HttpClient (default)
  • OkHttp
  • Jodd HTTP

Capabilities

Service Management

Core service initialization and configuration management.

interface WxMpService extends WxService {
  String getAccessToken() throws WxErrorException;
  String getAccessToken(boolean forceRefresh) throws WxErrorException;
  WxMpConfigStorage getWxMpConfigStorage();
  void setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider);
  boolean switchover(String mpId);
  WxMpService switchoverTo(String mpId);
}

Service Management

User Management

Comprehensive user information management, tagging, and blacklist operations.

interface WxMpUserService {
  WxMpUser userInfo(String openid, String lang) throws WxErrorException;
  List<WxMpUser> userInfoList(List<String> openids, String lang) throws WxErrorException;
  void userUpdateRemark(String openid, String remark) throws WxErrorException;
  WxMpUserList userList(String nextOpenid) throws WxErrorException;
}

User Management

Message Handling

Complete message processing framework including routing, handling, and response building.

class WxMpMessageRouter {
  WxMpMessageRouter rule();
  WxMpMessageRouterRule async(boolean async);
  WxMpMessageRouterRule handler(WxMpMessageHandler handler);
  WxMpXmlOutMessage route(WxMpXmlMessage message);
}

interface WxMpMessageHandler {
  WxMpXmlOutMessage handle(WxMpXmlMessage wxMessage, Map<String, Object> context, 
                          WxMpService wxMpService, WxSessionManager sessionManager) 
                          throws WxErrorException;
}

Message Handling

Material Management

Upload, download, and manage permanent and temporary media materials.

interface WxMpMaterialService {
  WxMediaUploadResult materialFileUpload(String mediaType, String fileName, InputStream inputStream) throws WxErrorException;
  WxMpMaterialUploadResult materialNewsUpload(WxMpMaterialNews news) throws WxErrorException;
  InputStream materialImageOrVoiceDownload(String mediaId) throws WxErrorException;
  WxMpMaterialVideoInfoResult materialVideoInfo(String mediaId) throws WxErrorException;
}

Material Management

Menu Management

Create, update, and delete custom menus for WeChat Official Accounts.

interface WxMpMenuService {
  String menuCreate(WxMenu menu) throws WxErrorException;
  void menuDelete() throws WxErrorException;
  WxMenu menuGet() throws WxErrorException;
  WxMpGetSelfMenuInfoResult getSelfMenuInfo() throws WxErrorException;
}

Menu Management

Template Messaging

Send template messages to users with dynamic content.

interface WxMpTemplateMsgService {
  WxMpTemplateMsgResult sendTemplateMsg(WxMpTemplateMessage templateMessage) throws WxErrorException;
  List<WxMpTemplate> getAllPrivateTemplate() throws WxErrorException;
  String addTemplate(String shortTemplateId) throws WxErrorException;
  boolean delPrivateTemplate(String templateId) throws WxErrorException;
}

Template Messaging

Shopping Guide Services

Comprehensive shopping guide functionality for managing shopping guides, buyers, materials, tags, and mass messaging campaigns.

interface WxMpGuideService {
  WxMpGuideResult addGuide(WxMpGuideAccount account) throws WxErrorException;
  WxMpGuideResult getGuide(String account, String guideOpenid) throws WxErrorException;
  WxMpGuideResult updateGuide(WxMpGuideAccount account) throws WxErrorException;
  WxMpGuideListResult getGuideList(Integer page, Integer num) throws WxErrorException;
}

interface WxMpGuideBuyerService {
  WxMpGuideBuyerResult addGuideBuyer(WxMpGuideBuyer buyer) throws WxErrorException;
  WxMpGuideBuyerListResult getGuideBuyerList(String guideAccount, Integer page, Integer num) throws WxErrorException;
  WxMpGuideBuyerRelationResult getGuideBuyerRelation(String guideAccount, String openid) throws WxErrorException;
}

interface WxMpGuideTagService {
  WxMpGuideTagResult newGuideTagOption(WxMpGuideTagOption tagOption) throws WxErrorException;
  WxMpGuideTagResult addGuideBuyerTag(String guideAccount, String openid, List<String> tagValueList) throws WxErrorException;
}

Shopping Guide Services

QR Code Management

Generate temporary and permanent QR codes for user engagement.

interface WxMpQrcodeService {
  WxMpQrCodeTicket qrCodeCreateTmp(int sceneId, Integer expireSeconds) throws WxErrorException;
  WxMpQrCodeTicket qrCodeCreateTmp(String sceneStr, Integer expireSeconds) throws WxErrorException;
  WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException;
  WxMpQrCodeTicket qrCodeCreateLastTicket(String sceneStr) throws WxErrorException;
  File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException;
  String qrCodePictureUrl(String ticket, boolean needShortUrl) throws WxErrorException;
}

QR Code Management, Customer Service, Analytics, and Other Services

Additional specialized services for WeChat Official Account functionality including QR code generation, customer service operations, data analytics, OAuth2 authentication, mass messaging, card management, and more.

Key services include:

interface WxMpQrcodeService {
  WxMpQrCodeTicket qrCodeCreateTmp(int sceneId, Integer expireSeconds) throws WxErrorException;
  WxMpQrCodeTicket qrCodeCreateLastTicket(int sceneId) throws WxErrorException;
  File qrCodePicture(WxMpQrCodeTicket ticket) throws WxErrorException;
}

interface WxMpKefuService {
  boolean sendKfMessage(WxMpKefuMessage message) throws WxErrorException;
  WxMpKfList kfList() throws WxErrorException;
  boolean kfAccountAdd(WxMpKfAccount account) throws WxErrorException;
}

interface WxMpDataCubeService {
  List<WxDataCubeUserSummary> getUserSummary(Date beginDate, Date endDate) throws WxErrorException;
  List<WxDataCubeArticleSummary> getArticleSummary(Date beginDate, Date endDate) throws WxErrorException;
}

interface WxOAuth2Service {
  String buildAuthorizationUrl(String redirectUri, String scope, String state);
  WxOAuth2AccessToken getAccessToken(String code) throws WxErrorException;
  WxOAuth2UserInfo getUserInfo(WxOAuth2AccessToken token, String lang) throws WxErrorException;
}

interface WxMpMassMessageService {
  WxMpMassSendResult massGroupMessageSend(WxMpMassGroupMessage message) throws WxErrorException;
  WxMpMassSendResult massOpenIdsMessageSend(WxMpMassOpenIdsMessage message) throws WxErrorException;
}

Advanced Services

Additional specialized services for extended WeChat functionality including analytics, OAuth2, mass messaging, and specialized integrations.

Key services include:

  • Analytics & Data: Data cube services for user and content analytics
  • OAuth2 Authentication: Web-based user authorization and profile access
  • Mass Messaging: Bulk message sending to user groups or segments
  • Store Management: Location-based services and POI management
  • Device Management: IoT device integration and communication
  • AI Services: Voice recognition, translation, and image processing
  • Invoice Services: Electronic invoice management and reimbursement
  • Card Management: Membership cards, coupons, and loyalty programs
  • WiFi Services: WiFi portal management and user engagement

Advanced Services

Configuration Types

interface WxMpConfigStorage {
  String getAccessToken();
  boolean isAccessTokenExpired();
  void expireAccessToken();
  void updateAccessToken(WxAccessToken accessToken);
  String getAppId();
  String getSecret();
  String getToken();
  String getAesKey();
  long getExpiresTime();
  String getOAuth2redirectUri();
  String getHttpProxyHost();
  int getHttpProxyPort();
  String getHttpProxyUsername();
  String getHttpProxyPassword();
}

class WxMpHostConfig {
  public static String buildUrl(WxMpHostConfig hostConfig, String prefix, String path);
  // Host configuration for different deployment environments
}

Exception Handling

class WxErrorException extends Exception {
  private WxError error;
  public WxError getError();
  public String getMessage();
}

class WxError implements Serializable {
  private int errorCode;
  private String errorMsg;
  private String json;
  // Error details and codes
}

Message Types

class WxMpXmlMessage implements Serializable {
  private String toUser;
  private String fromUser;
  private Long createTime;
  private String msgType;
  private String content;
  private Long msgId;
  private String picUrl;
  private String mediaId;
  // Additional message fields based on type
}

abstract class WxMpXmlOutMessage {
  protected String toUserName;
  protected String fromUserName;
  protected Long createTime;
  protected String msgType;
  // Base class for all outgoing messages
}

Constants

class WxMpEventConstants {
  // Card Events
  public static final String CardPass = "card_pass_check";
  public static final String CardNotPass = "card_not_pass_check";
  public static final String UserGetCard = "user_get_card";
  public static final String UserGiftingCard = "user_gifting_card";
  public static final String UserDelCard = "user_del_card";
  public static final String UserConsumeCard = "user_consume_card";
  public static final String UserPayFromPayCell = "user_pay_from_pay_cell";
  public static final String UserViewCard = "user_view_card";
  public static final String UserEnterSessionFromCard = "user_enter_session_from_card";
  public static final String UpdateMemberCard = "update_member_card";
  public static final String CardSkuRemind = "card_sku_remind";
  public static final String CardPayOrder = "card_pay_order";
  public static final String SubmitMembercardUserInfo = "submit_membercard_user_info";

  // Store Events  
  public static final String PoiCheckNotify = "poi_check_notify";

  // Shake Events
  public static final String ShakeAroundUserShake = "ShakeAround_user_shake";
  public static final String ShakeAroundLotteryBind = "ShakeAround_lottery_bind";
}

enum WxMpApiUrl {
  // Comprehensive API endpoint definitions organized by category
  // Device, OAuth2, Menu, Material, User, Card, etc.
}