You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
PHP
79 lines
2.6 KiB
PHP
<?php
|
|
|
|
class PddOAuthUtil {
|
|
/**
|
|
*
|
|
* @var PddOAuthClient
|
|
*/
|
|
public static $oauthClient = null;
|
|
public static $isLockConfigApp = false;
|
|
|
|
public static function getPddOAuthClient() {
|
|
if (self::$oauthClient) {
|
|
return self::$oauthClient;
|
|
}
|
|
self::$oauthClient = new PddOAuthClient(Zc::C('gatewayUrl'), Zc::C('clientId'), Zc::C('clientSecret'), RedisExt::factory('statCache'));
|
|
return self::$oauthClient;
|
|
}
|
|
|
|
public static function configCurrApp($appCategory, $mallId = null) {
|
|
if (self::$isLockConfigApp) {
|
|
return true;
|
|
}
|
|
|
|
if (empty($appCategory)) {
|
|
$appCategory = Zc::C('appCategory');
|
|
}
|
|
if (!empty($mallId)) {
|
|
$_SESSION[SessionConst::mallId] = $mallId;
|
|
}
|
|
|
|
$appConfig = Zc::C('app');
|
|
$clientId = $appConfig[$appCategory]['clientId'];
|
|
$clientSecret = $appConfig[$appCategory]['clientSecret'];
|
|
|
|
Zc::C('appCategory', $appCategory);
|
|
Zc::C('clientId', $clientId);
|
|
Zc::C('clientSecret', $clientSecret);
|
|
|
|
$oauthClient = self::getPddOAuthClient();
|
|
$oauthClient->clientId = $clientId;
|
|
$oauthClient->clientSecret = $clientSecret;
|
|
return true;
|
|
}
|
|
|
|
public static function configCurrAppByAppName($useAppName) {
|
|
switch ($useAppName) {
|
|
case AppConst::appPddDzSh:
|
|
$clientId = Zc::C('dzshClientId');
|
|
$clientSecret = Zc::C('dzshClientSecret');
|
|
break;
|
|
default:
|
|
$clientId = Zc::C('clientId');
|
|
$clientSecret = Zc::C('clientSecret');
|
|
break;
|
|
}
|
|
|
|
$oauthClient = self::getPddOAuthClient();
|
|
$oauthClient->clientId = $clientId;
|
|
$oauthClient->clientSecret = $clientSecret;
|
|
$oauthClient->useAppName = $useAppName;
|
|
self::$isLockConfigApp = true;
|
|
return true;
|
|
}
|
|
|
|
public static function buildWbAuthUrl() {
|
|
$authUrl = sprintf('%s?client_id=%s&redirect_uri=%s', Zc::C('wbAuthorizeUrl'), Zc::C('wbClientId'), Zc::C('wbRedirectUri'));
|
|
return $authUrl;
|
|
}
|
|
|
|
public static function buildPddAuthUrl() {
|
|
return sprintf('https://fuwu.pinduoduo.com/service-market/auth?client_id=%s&response_type=code&redirect_uri=%s', Zc::C('clientId'), urlencode(Zc::url(RouteConst::userUserCallback)));
|
|
}
|
|
|
|
public static function buildPddAuthLogisticsUrl() {
|
|
return sprintf('https://wb.pinduoduo.com/logistics/auth?client_id=%s&response_type=code&redirect_uri=%s', Zc::C('clientId'), urlencode(Zc::url(RouteConst::userUserCallback, '', 'http')));
|
|
}
|
|
|
|
|
|
} |