Authored by whb

修改微信

... ... @@ -192,6 +192,7 @@ EOT;
public function detailAction()
{
$id = intval($this->_request->id);
$link = SITE_MAIN.url('news/detail', array('id' => $id));
$news = array();
if (empty($id))
{
... ... @@ -214,7 +215,7 @@ EOT;
$news = array($temp['id'] => $temp);
}
$news = array_slice(array_filter($news + $temp2), 0, 3);
$this->_view['wechat'] = Lib_Wechat_JSSDK::getSignPackage();
$this->_view['wechat'] = Lib_Wechat_JSSDK::getSignPackage($link);
}
$info['title'] = strip_tags($info['title']);
$info['pics'] = array_filter(explode('|', $info['pics']));
... ...
... ... @@ -3,7 +3,7 @@ class Lib_Wechat_JSSDK {
public static $appId = YOHO_WECHAT_APPID;
public static $appSecret = YOHO_WECHAT_APPSECRET;
public static function getSignPackage()
public static function getSignPackage($url = '')
{
$jsapiTicket = self::getJsApiTicket();
... ... @@ -11,7 +11,6 @@ class Lib_Wechat_JSSDK {
/* $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; */
// 确保你获取用来签名的url是动态获取的,动态页面可参见实例代码中php的实现方式。如果是html的静态页面在前端通过ajax将url传到后台签名,前端需要用js获取当前页面除去'#'hash部分的链接(可用location.href.split('#')[0]获取),因为页面一旦分享,微信客户端会在你的链接末尾加入其它参数,如果不是动态获取当前链接,将导致分享后的页面签名失败。
$url = '';
$timestamp = time();
$nonceStr = self::createNonceStr();
... ...