正在显示
1 个修改的文件
包含
0 行增加
和
47 行删除
src/Passage/Authorize.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -namespace Lackoxygen\TiktokShop\Passage; | ||
| 4 | - | ||
| 5 | -use Illuminate\Support\Arr; | ||
| 6 | - | ||
| 7 | -class Authorize extends Passage | ||
| 8 | -{ | ||
| 9 | - /** | ||
| 10 | - * @param string $code | ||
| 11 | - * @param string $grantType {authorization_self, authorization_code} | ||
| 12 | - * @param bool $sandbox | ||
| 13 | - * @return ResultSet | ||
| 14 | - */ | ||
| 15 | - public function token(string $code, string $grantType = 'authorization_code', bool $sandbox = false) | ||
| 16 | - { | ||
| 17 | - $params = ['code' => $code, 'grant_type' => $grantType]; | ||
| 18 | - if ($sandbox) { | ||
| 19 | - if ($grantType === 'authorization_self') { | ||
| 20 | - if ($code == '4463798') { | ||
| 21 | - Arr::set($params, 'test_shop', 1); | ||
| 22 | - } else { | ||
| 23 | - Arr::set($params, 'shop_id', $code); | ||
| 24 | - } | ||
| 25 | - } | ||
| 26 | - } | ||
| 27 | - $this->builder->service('token.create'); | ||
| 28 | - $this->builder | ||
| 29 | - ->method('GET') | ||
| 30 | - ->path('/token/create') | ||
| 31 | - ->service('token.create') | ||
| 32 | - ->params($params); | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * @param string $refreshToken | ||
| 37 | - * @param string $grantType | ||
| 38 | - * @return ResultSet | ||
| 39 | - */ | ||
| 40 | - public function refresh(string $refreshToken, string $grantType = 'refresh_token') | ||
| 41 | - { | ||
| 42 | - $this->builder | ||
| 43 | - ->method('POST') | ||
| 44 | - ->service('token.refresh') | ||
| 45 | - ->params(['refresh_token' => $refreshToken, 'grant_type' => $grantType]); | ||
| 46 | - } | ||
| 47 | -} |
-
请 注册 或 登录 后发表评论