導航:首頁 > 編程語言 > 微信公眾平台開發java源碼

微信公眾平台開發java源碼

發布時間:2022-12-23 04:58:22

1. 怎麼搭建微信公眾平台java開發環境

這個比較復雜,首先需要申請一個微信公眾的訂閱好或服務號,還要開通各種介面,然後在本地安裝java開發環境,包括開發工具如eclipse,myeclipse。最重要的是能在公網有一個地址映射到本地,如果是在區域網,則需要藉助第三方工具,推薦使用花生殼、nat123,其中nat123是個比較好的工具,很好的解決了運營商80埠封鎖的問題,因為微信公眾平台配置伺服器的URL只能是80埠。

2. java微信公眾平台開發的實現原理是什麼具體如何實現呢最好有java源碼

推薦一個學習的資料:
http://blog.csdn.net/lyq8479/article/category/1366622/2
邊看邊學習應該就會了。記得採納啊~~

3. 微信公眾平台可以用java寫嗎

可以,我現在的項目就是java後台開發的微信公眾平台,唯一要注意的就是公眾平台openid的使用

4. 如何使用jsp開發微信公眾平台,或者使用java語言開發公眾平台

一句話 按照微信的規定開發:網路微信公眾號開API ; 申請伺服器 ; 申請公眾號 ;綁定 ,開通許可權等 ;我們一直在用 jsp 、java開發。

5. Java 開發 微信公眾平台開發 URL驗證

和訂閱號和服務號不一樣,企業號只有企業通信錄員工才能關

注,同時,一個企業號可以配置多個類似的服務號應用,發送信息

的條數無限制,還能對信息進行安全設置,確保信息的安全性和私密

性。

企業號申請和訂閱號以及服務號申請的前期准備和步驟相

同。比如,准備好一個注冊郵箱,然後進行郵箱驗證。但是從驗證之後

的申請步驟就有所區別了。在郵箱激活後,用戶進入選擇賬號類型,選

擇點擊「企業號」,會彈出溫馨提示對話框,提醒選擇企業號後不可更

改,是否繼續操作,點擊「確認」,進入用戶信息登記頁面。

6. 如何使用微信sdk java版

1.首先我們新建一個Java開發包WeiXinSDK
2.包路徑:com.ansitech.weixin.sdk
測試的前提條件:
假如我的公眾賬號微信號為:vzhanqun
我的伺服器地址為:http://www.vzhanqun.com/
下面我們需要新建一個URL的請求地址

我們新建一個Servlet來驗證URL的真實性,具體介面參考
http://mp.weixin.qq.com/wiki/index.php?title=接入指南

3.新建com.ansitech.weixin.sdk.WeixinUrlFilter.java
這里我們主要是獲取微信伺服器法師的驗證信息,具體驗證代碼如下

[java] view plain print?
package com.ansitech.weixin.sdk;

import com.ansitech.weixin.sdk.util.SHA1;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class WeixinUrlFilter implements Filter {

//這個Token是給微信開發者接入時填的
//可以是任意英文字母或數字,長度為3-32字元
private static String Token = "vzhanqun1234567890";

@Override
public void init(FilterConfig config) throws ServletException {
System.out.println("WeixinUrlFilter啟動成功!");
}

@Override
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
//微信伺服器將發送GET請求到填寫的URL上,這里需要判定是否為GET請求
boolean isGet = request.getMethod().toLowerCase().equals("get");
System.out.println("獲得微信請求:" + request.getMethod() + " 方式");
if (isGet) {
//驗證URL真實性
String signature = request.getParameter("signature");// 微信加密簽名
String timestamp = request.getParameter("timestamp");// 時間戳
String nonce = request.getParameter("nonce");// 隨機數
String echostr = request.getParameter("echostr");//隨機字元串
List<String> params = new ArrayList<String>();
params.add(Token);
params.add(timestamp);
params.add(nonce);
//1. 將token、timestamp、nonce三個參數進行字典序排序
Collections.sort(params, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.compareTo(o2);
}
});
//2. 將三個參數字元串拼接成一個字元串進行sha1加密
String temp = SHA1.encode(params.get(0) + params.get(1) + params.get(2));
if (temp.equals(signature)) {
response.getWriter().write(echostr);
}
} else {
//處理接收消息
}
}

@Override
public void destroy() {

}
}
好了,不過這里有個SHA1演算法,我這里也把SHA1演算法的源碼給貼出來吧!

4.新建com.ansitech.weixin.sdk.util.SHA1.java

[java] view plain print?
/*
* 微信公眾平台(JAVA) SDK
*
* Copyright (c) 2014, Ansitech Network Technology Co.,Ltd All rights reserved.
* http://www.ansitech.com/weixin/sdk/
*
* 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 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.
*/
package com.ansitech.weixin.sdk.util;

import java.security.MessageDigest;

/**
* <p>Title: SHA1演算法</p>
*
* @author qsyang<[email protected]>
*/
public final class SHA1 {

private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};

/**
* Takes the raw bytes from the digest and formats them correct.
*
* @param bytes the raw bytes from the digest.
* @return the formatted bytes.
*/
private static String getFormattedText(byte[] bytes) {
int len = bytes.length;
StringBuilder buf = new StringBuilder(len * 2);
// 把密文轉換成十六進制的字元串形式
for (int j = 0; j < len; j++) {
buf.append(HEX_DIGITS[(bytes[j] >> 4) & 0x0f]);
buf.append(HEX_DIGITS[bytes[j] & 0x0f]);
}
return buf.toString();
}

public static String encode(String str) {
if (str == null) {
return null;
}
try {
MessageDigest messageDigest = MessageDigest.getInstance("SHA1");
messageDigest.update(str.getBytes());
return getFormattedText(messageDigest.digest());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
5.把這個Servlet配置到web.xml中

[html] view plain print?
<filter>
<description>微信消息接入介面</description>
<filter-name>WeixinUrlFilter</filter-name>
<filter-class>com.ansitech.weixin.sdk.WeixinUrlFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>WeixinUrlFilter</filter-name>
<url-pattern>/api/vzhanqun</url-pattern>
</filter-mapping>
好了,接入的開發代碼已經完成。

6.下面就把地址URL和密鑰Token填入到微信申請成為開發者模式中吧。

7. 微信公眾平台自定義菜單java開發

對於微信自定義菜單,

8. 如何使用java開發微信公眾平台介面

1、首先,要在微信公眾平台給你的賬號申請到「高級功能」 ;前台也就是菜單要想個性化設置必須要有這個功能,不然你只能添加菜單和關閉,但不能刪除,還有自動回復也是。
2、後台要看你自己了。

9. 如果想使用java進行微信公眾平台開發至少需要掌握哪些內容

開發用的是HTML5開發的
你還需要去後台開發者中心下載騰訊提供的源碼文件

閱讀全文

與微信公眾平台開發java源碼相關的資料

熱點內容
dvd光碟存儲漢子演算法 瀏覽:757
蘋果郵件無法連接伺服器地址 瀏覽:962
phpffmpeg轉碼 瀏覽:671
長沙好玩的解壓項目 瀏覽:144
專屬學情分析報告是什麼app 瀏覽:564
php工程部署 瀏覽:833
android全屏透明 瀏覽:737
阿里雲伺服器已開通怎麼辦 瀏覽:803
光遇為什麼登錄時伺服器已滿 瀏覽:302
PDF分析 瀏覽:484
h3c光纖全工半全工設置命令 瀏覽:143
公司法pdf下載 瀏覽:381
linuxmarkdown 瀏覽:350
華為手機怎麼多選文件夾 瀏覽:683
如何取消命令方塊指令 瀏覽:349
風翼app為什麼進不去了 瀏覽:778
im4java壓縮圖片 瀏覽:362
數據查詢網站源碼 瀏覽:150
伊克塞爾文檔怎麼進行加密 瀏覽:892
app轉賬是什麼 瀏覽:163