public dynamic GetSignature(string AppId, string AppName, string url, string access_token) { string ticket = GetTicket(AppName, access_token).ticket; var model = new JsConfigModel(); model.appId = AppId; model.nonceStr = Guid.NewGuid().ToString(); model.timestamp = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; string str = "jsapi_ticket=" + ticket + "&noncestr=" + model.nonceStr + "×tamp=" + model.timestamp + "&url=" + url + ""; model.signature = FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1").ToLower(); return(model); }
public HttpResponseMessage GetJSConfig() { try { var model = new JsConfigModel { appId = _wcCommonService.AppId, debug = true, jsApiList = new[] { "onMenuShareTimeline", "onMenuShareAppMessage", "onMenuShareQQ", "onMenuShareWeibo", "startRecord", "stopRecord", "onVoiceRecordEnd", "playVoice", "pauseVoice", "stopVoice", "onVoicePlayEnd", "uploadVoice", "downloadVoice", "chooseImage", "previewImage", "uploadImage", "downloadImage", "translateVoice", "getNetworkType", "openLocation", "getLocation", "hideOptionMenu", "showOptionMenu", "hideMenuItems", "showMenuItems", "hideAllNonBaseMenuItem", "showAllNonBaseMenuItem", "closeWindow", "scanQRCode", "chooseWXPay", "openProductSpecificView", "addCard", "chooseCard", "openCard" }, nonceStr = _helper.GenerateNonceStr(), timestamp = _helper.GenerateTimeStamp() }; var dic = new SortedDictionary <string, string> { { "timestamp", model.timestamp }, { "nonceStr", model.nonceStr }, { "jsapi_ticket", _wcCommonService.JsAPITicket }, { "url", Request.RequestUri.AbsoluteUri } }; model.signature = _wcCommonService.MakeSign(dic); return(PageHelper.toJson(new ResultModel() { Msg = "获取配置文件成功", Object = model, Status = true })); } catch (Exception e) { return(PageHelper.toJson(new ResultModel() { Msg = "获取配置文件失败", Status = false })); } }