直接上**:
1、傳送請求獲取jsapiticket
publicclass
jsapiticketutil
in.close();
} catch
(ioexception e)
}catch
(malformedurlexception e)
return
result;
}/***
* 獲取jsapiticket的憑證票據
* @return
*/public
static
string getjsapiticket()
//測試
public
static
void
main(string args)
}
2、生成配置引數
/*** 獲取timestamp,noncestr,signature三個引數(頁面配置js)
* 工具類
* @author
xcg * @date 2018.01.09 */
public
class
generateconfigparame
catch
(nosuchalgorithmexception e)
catch
(unsupportedencodingexception e)
ret.put("url", url);
ret.put("jsapi_ticket", jsapi_ticket);
ret.put("noncestr", nonce_str);
ret.put("timestamp", timestamp);
ret.put("signature", signature);
return
ret;
}/*** byte轉換為16進製制字串
* @param
hash
* @return
*/private
static string bytetohex(final
byte
hash)
string result =formatter.tostring();
formatter.close();
return
result;
}/*** 建立隨機串
* @return
*/private
static
string create_nonce_str()
/*** 建立時間戳
* @return
*/private
static
string create_timestamp()
}
publicclass
wxjsinit
}
4、前台頁面初始化jssdk
//wx.config(' , //
必填,生成簽名的時間戳
noncestr: '$', //
必填,生成簽名的隨機串
signature: '$',//
必填,簽名,見附錄1
jsapilist: ['chooseimage',//
選擇 'uploadimage',//
上傳 'downloadimage',//
'previewimage'//
預覽
] //
必填,需要使用的js介面列表,所有js介面列表見附錄2
});
wx.error(
function
(res) );
wx.ready(
function
() );
5、開啟wx.config({})中,debug:true,頁面彈出字樣,及配置完成
6、若配置失敗,則檢查js介面網域名稱配置是否有誤,參考官方提示配置js介面網域名稱即可!
微信 JSSDK開發
js介面安全網域名稱設定 mi.com 前面不用帶www http,網域名稱必須備案過 2.引入js檔案 在需要呼叫js介面的頁面引入如下js檔案,支援https 3.通過config介面注入許可權驗證配置 wx.config 4.通過ready介面處理成功驗證 wx.ready function ...
微信jssdk使用
使用jssdk之前,我們需要在伺服器端準備什麼資料 jssdk使用的config wx.config 這裡我們需要自己去準備的資料,主要有 timestamp 這個一般可用伺服器當前時間設值,php now noncestr 隨機的字串,這個字串可以任意長度,自己設定隨機串 signature 簽名...
微信JSSDK使用
1.步驟一 繫結網域名稱 2.步驟二 引入js檔案 3.步驟三 通過config介面注入許可權驗證配置 wx.config 必填,生成簽名的時間戳 noncestr 必填,生成簽名的隨機串 signature 必填,簽名 jsapilist getlocation openlocation 必填,需...