// 贴上jssdk一段代码
public function getSignPackage() { $jsapiTicket = $this->getJsApiTicket(); $url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; $timestamp = time(); $nonceStr = $this->createNonceStr(); // 这里参数的顺序要按照 key 值 ASCII 码升序排序 $string = "jsapi_ticket=$jsapiTicket&noncestr=$nonceStr×tamp=$timestamp&url=$url"; $signature = sha1($string); $signPackage = array( "jsapiTicket" => $jsapiTicket, "appId" => $this->appId, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url, "signature" => $signature, "rawString" => $string ); return $signPackage; }
1.微信公众号菜单链接配置的http,生成签名用的https协议导致签名错误。【解决办法:统一协议】