Skip to content

Commit

Permalink
🌮 0.7.3 修正令牌逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
metowolf committed Apr 28, 2018
1 parent 43d0a76 commit 5e9e89d
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# iOS 6620
# iOS 6670
APP_KEY=27eb53fc9058f8c3
APP_SECRET=c2ed53a74eeefe3cf99fbd01d8c9c375

Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Release Notes

## v0.7.3 (2018-04-28)

### Added
- 新增帐号别名参数

### Changed
- 更新模拟客户端版本 (iOS 6670)
- 修正环境变量刷新逻辑

### Fixed
- 修复部分语法错误
- 修复错误信息回调函数逻辑错误


## v0.7.2 (2018-04-22)

### Added
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "metowolf/bilibili",
"version": "0.7.0",
"description": "B 站自动领瓜子、直播挂机脚本",
"type": "project",
"require": {
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
21 changes: 12 additions & 9 deletions src/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions src/Sign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 5e9e89d

Please sign in to comment.