diff --git a/.env b/.env index 37205de..f01c5db 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -# iOS 6620 +# iOS 6670 APP_KEY=27eb53fc9058f8c3 APP_SECRET=c2ed53a74eeefe3cf99fbd01d8c9c375 diff --git a/CHANGELOG.md b/CHANGELOG.md index ad14e35..748925d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Release Notes +## v0.7.3 (2018-04-28) + +### Added +- 新增帐号别名参数 + +### Changed +- 更新模拟客户端版本 (iOS 6670) +- 修正环境变量刷新逻辑 + +### Fixed +- 修复部分语法错误 +- 修复错误信息回调函数逻辑错误 + + ## v0.7.2 (2018-04-22) ### Added diff --git a/composer.json b/composer.json index e63f92d..40ca159 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,5 @@ { "name": "metowolf/bilibili", - "version": "0.7.0", "description": "B 站自动领瓜子、直播挂机脚本", "type": "project", "require": { diff --git a/composer.lock b/composer.lock index b82e43a..9c73f4e 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3982e326cdc952573152cb10b6989b40", + "content-hash": "754a5e797e44122a108386a2bed581fb", "packages": [ { "name": "bramus/ansi-php", diff --git a/src/Curl.php b/src/Curl.php index 82ebf4f..72530a9 100644 --- a/src/Curl.php +++ b/src/Curl.php @@ -21,7 +21,7 @@ class Curl 'Accept-Language' => 'zh-cn', 'Connection' => 'keep-alive', 'Content-Type' => 'application/x-www-form-urlencoded', - 'User-Agent' => 'User-Agent: bili-universal/6620 CFNetwork/897.15 Darwin/17.5.0', + 'User-Agent' => 'User-Agent: bili-universal/6670 CFNetwork/897.15 Darwin/17.5.0', ); public static function post($url, $payload = null) diff --git a/src/Log.php b/src/Log.php index ce33cc1..ec0d6a5 100644 --- a/src/Log.php +++ b/src/Log.php @@ -3,7 +3,7 @@ /*! * metowolf BilibiliHelper * https://i-meto.com/ - * Version 18.04.21 + * Version 18.04.28 * * Copyright 2018, laverboy & metowolf * https://gist.github.com/laverboy/fd0a32e9e4e9fbbf9584 @@ -85,7 +85,7 @@ public static function error($message, array $context = []) public static function callback($levelId, $level, $message) { - $callback_level = empty(getenv('APP_CALLBACK_LEVEL')) ? (Logger::ERROR) : intval(getenv('APP_CALLBACK_LEVEL')); + $callback_level = (getenv('APP_CALLBACK_LEVEL') === false) ? (Logger::ERROR) : intval(getenv('APP_CALLBACK_LEVEL')); if ($levelId >= $callback_level) { $url = str_replace('{account}', self::prefix(), getenv('APP_CALLBACK')); $url = str_replace('{level}', $level, $url); diff --git a/src/Login.php b/src/Login.php index 3b8ca6b..b966cf8 100644 --- a/src/Login.php +++ b/src/Login.php @@ -22,7 +22,7 @@ class Login public static function run() { Log::info('正在装载终端'); - if (empty(getenv('ACCESS_TOKEN'))) { + if (getenv('ACCESS_TOKEN') == "") { Log::info('令牌载入中...'); self::login(); } @@ -99,12 +99,8 @@ public static function refresh() Log::info('令牌生成完毕!'); $access_token = $data['data']['access_token']; - self::writeNewEnvironmentFileWith('ACCESS_TOKEN', $access_token); - Log::info(' > access token: '.$access_token); - $refresh_token = $data['data']['refresh_token']; - self::writeNewEnvironmentFileWith('REFRESH_TOKEN', $refresh_token); - Log::info(' > refresh token: '.$refresh_token); + self::overload($access_token, $refresh_token); return true; } @@ -160,14 +156,21 @@ protected static function login() Log::info('令牌获取成功!'); $access_token = $data['data']['token_info']['access_token']; + $refresh_token = $data['data']['token_info']['refresh_token']; + self::overload($access_token, $refresh_token); + + return; + } + + protected static function overload($access_token, $refresh_token) + { self::writeNewEnvironmentFileWith('ACCESS_TOKEN', $access_token); + putenv('ACCESS_TOKEN='.$access_token); Log::info(' > access token: '.$access_token); - $refresh_token = $data['data']['token_info']['refresh_token']; self::writeNewEnvironmentFileWith('REFRESH_TOKEN', $refresh_token); + putenv('REFRESH_TOKEN='.$refresh_token); Log::info(' > refresh token: '.$refresh_token); - - return; } protected static function writeNewEnvironmentFileWith($key, $value) diff --git a/src/Sign.php b/src/Sign.php index 0355c97..eccbc88 100644 --- a/src/Sign.php +++ b/src/Sign.php @@ -19,8 +19,7 @@ public static function api($payload) 'access_key' => getenv('ACCESS_TOKEN'), 'actionKey' => 'appkey', 'appkey' => getenv('APP_KEY'), - 'appver' => '6620', - 'build' => '6620', + 'build' => '6670', 'device' => 'phone', 'mobi_app' => 'iphone', 'platform' => 'ios',