1、微信报错 config:invalid signature( 这个错误是签名不对,需要检查的地方有)
1.1 除了签名参数字母顺序
1.2 url 参数需要用encodeURIComponent 方法处理一下,如下:
var param = { url: encodeURIComponent(location.href.split('#')[0]) }
Swao.utils.SiteRest.operate(objName, param, SuccessFn, fnOption);
1.3 有时候加载过快,加载前url和加载后的url参数可能不一致,所以需要晚上几秒进行签名,如下:
注意:这种情况,经常出现在 网页授权签名等页面,创建分享的时候出现,页面加载完成钱有code参数,加载完了后code参数就不见了
<script type="text/javascript">
$(document).ready(function () {
setTimeout(function () {
df.Common.WeiXin.PageLoading('', ReadyFuction);
}, 3000)
});
function ReadyFuction() {
wx.ready(function () {
df.WeiXin.MangoMenuShare("<%=strShareImg %>", "<%=strShareTitle %>", "<%=strShareDesc %>", "<%=strShareUrl %>");
});
}
</script>
2、就是自定义的url链接失效
因为,当前微信不支持非常复杂的url,例如:
strShareUrl = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={2}&redirect_uri=http://{3}/MyShare/MangoShare.aspx?id={0}@{1}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect"
, iCouponId, strUserId, this.MiddleTier.SysConfigManager.GetByCodeDK("WX_AppId").Value, this.MiddleTier.SysConfigManager.GetByCodeDK("WxWebUrl").Value);
对于这种情况,需要将分享页面简化,然后做二次调整,思路如下:
2.1 首先只使用简单的参数,跳转到中间装换页面
strShareUrl = string.Format("middConvertPage.aspx?type=fx&Newid={0}&Pid={1}", iNewId, iSharPid);
2.2 接着,中间页面做跳转
if (Request.QueryString["type"].ToString() == "fx")
{
int iNewId = Convert.ToInt32(Request.QueryString["Newid"]);
int iPid = Convert.ToInt32(Request.QueryString["Pid"]);
string strShareUrl = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx11582cf839dd8596&redirect_uri=http://acwxone.eshanghai.cn/Info/NewsDetail.aspx?id={0}@{1}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect", iNewId, iPid);
Response.Redirect(strShareUrl);
}