|
|
@@ -39,13 +39,14 @@ class Auth
|
|
|
*/
|
|
|
public function __construct()
|
|
|
{
|
|
|
- $isProduction = getenv('YII_ENV') == 'production'; // TODO
|
|
|
+ $isProduction = getenv('YII_ENV') == 'production';
|
|
|
|
|
|
if ($isProduction) {
|
|
|
// 生产环境配置(需要替换为实际的生产环境凭证)
|
|
|
$this->appKey = 'dadaf2279d901a5ba40';
|
|
|
$this->appSecret = '828a03677a1c00a3a5b3c59209c4433d';
|
|
|
- $this->redirectUri = Yii::$app->params['ghsHost'].'/delivery/dada-auth-callback';
|
|
|
+ // TODO
|
|
|
+ $this->redirectUri = 'https://api.shop.hzghd.com' . '/delivery/dada-auth-callback'; // TODO Yii::$app->params['ghsHost'].'/delivery/dada-auth-callback';
|
|
|
$this->authorizeUrl = self::AUTHORIZE_URL_PROD;
|
|
|
$this->tokenUrl = self::TOKEN_URL_PROD;
|
|
|
} else {
|
|
|
@@ -79,7 +80,6 @@ class Auth
|
|
|
{
|
|
|
// 生成随机数
|
|
|
$nonce = $this->generateNonce(15);
|
|
|
- //$nonce = 'VV7JK4BJXAUSYP8'; // 写死,后期修改回去
|
|
|
|
|
|
// 生成签名
|
|
|
$sign = $this->generateTicketSign($nonce);
|
|
|
@@ -177,33 +177,14 @@ class Auth
|
|
|
];
|
|
|
|
|
|
// 第一步
|
|
|
- // 按键排序
|
|
|
- //ksort($signParams, SORT_STRING);
|
|
|
- // 按值排序且不改变key
|
|
|
- //asort($signParams);
|
|
|
sort($signParams, SORT_STRING);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
// 第二步:拼接所有参数值
|
|
|
$signString = implode('', $signParams);
|
|
|
|
|
|
- // 第二步:拼接 key 和 value
|
|
|
- // $signString = '';
|
|
|
- // foreach ($signParams as $key => $value) {
|
|
|
- // $signString .= $key . $value;
|
|
|
- // }
|
|
|
- // $signString = $signString;
|
|
|
-
|
|
|
// 第三步:SHA1 加密
|
|
|
$hex = sha1($signString);
|
|
|
|
|
|
- // $len = 36;
|
|
|
- // if ($len < strlen($hex)) {
|
|
|
- // $hex = substr($hex, 0, $len);
|
|
|
- // }
|
|
|
-
|
|
|
- //return strtoupper(substr($hex, 0, 36));
|
|
|
- //return strtoupper($hex);
|
|
|
return $hex;
|
|
|
}
|
|
|
|