...
|
...
|
@@ -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();
|
...
|
...
|
|