Authored by whb

测试bug

... ... @@ -45,7 +45,7 @@ class Controller_Default extends Controller_Abstract
public function testAction()
{
$link = SITE_MAIN.url('default/test');
$this->_view['wechat'] = Lib_Wechat_JSSDK::getSignPackage($link);
$this->_view['wechat'] = Lib_Wechat_JSSDK::getSignPackage();
}
public function contactusAction()
{
... ...
... ... @@ -3,13 +3,14 @@ class Lib_Wechat_JSSDK {
public static $appId = YOHO_WECHAT_APPID;
public static $appSecret = YOHO_WECHAT_APPSECRET;
public static function getSignPackage($url = '')
public static function getSignPackage()
{
$jsapiTicket = self::getJsApiTicket();
// 注意 URL 一定要动态获取,不能 hardcode.
/* $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; */
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $url;
// 确保你获取用来签名的url是动态获取的,动态页面可参见实例代码中php的实现方式。如果是html的静态页面在前端通过ajax将url传到后台签名,前端需要用js获取当前页面除去'#'hash部分的链接(可用location.href.split('#')[0]获取),因为页面一旦分享,微信客户端会在你的链接末尾加入其它参数,如果不是动态获取当前链接,将导致分享后的页面签名失败。
$timestamp = time();
$nonceStr = self::createNonceStr();
... ...
... ... @@ -11,7 +11,7 @@
</head>
<body>
test
</body>
<script type="text/javascript" charset="utf-8" src="http://staticzine.myoho.net/download/jquery.min.js?v=20150429"></script>
<script type="text/javascript" charset="utf-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
... ... @@ -55,5 +55,4 @@ wx.error(function (res) {
alert(res.errMsg);
});
</script>
</body>
</html>
\ No newline at end of file
... ...