diff --git a/src/Factory.php b/src/Factory.php index 712be0d0e724ad31022440ddc9a23f4e5c13e0d1..ac590adefd0b40b0b74c533921755e4dfec746da 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -16,14 +16,13 @@ use Illuminate\Support\Str; /** * Class Factory. * - * @method static Codeinfo\LaravelBytedance\Platform\Application platform(array $config) + * @method static Codeinfo\LaravelBytedance\Platform\Application platform(array $config) */ class Factory { /** - * @param string $name - * @param array $config - * + * @param string $name + * @param array $config * @return Codeinfo\LaravelBytedance\Kernel\ServiceContainer */ public static function make($name, array $config) @@ -37,9 +36,8 @@ class Factory /** * Dynamically pass methods to the application. * - * @param string $name - * @param array $arguments - * + * @param string $name + * @param array $arguments * @return mixed */ public static function __callStatic($name, $arguments) diff --git a/src/Kernel/Client.php b/src/Kernel/Client.php index e9e72f76cba69896b86686be8dba13a911e11fd0..96e842fe2069c623aa8ca6729963e4094f207555 100644 --- a/src/Kernel/Client.php +++ b/src/Kernel/Client.php @@ -12,8 +12,6 @@ namespace Codeinfo\LaravelBytedance\Kernel; use Codeinfo\LaravelBytedance\Kernel\Http\Request; -use GuzzleHttp\Psr7\LazyOpenStream; -use Illuminate\Support\Facades\Log; class Client extends Request { @@ -27,7 +25,7 @@ class Client extends Request /** * Client constructor. * - * @param \Codeinfo\LaravelBytedance\Kernel\ServiceContainer $app + * @param \Codeinfo\LaravelBytedance\Kernel\ServiceContainer $app */ public function __construct(ServiceContainer $app) { @@ -39,8 +37,8 @@ class Client extends Request /** * Http Get. * - * @param string $url - * @param array $query + * @param string $url + * @param array $query * @return mixed */ public function httpGet(string $url, array $query = [], $header = []) @@ -56,8 +54,8 @@ class Client extends Request /** * Http Post Json. * - * @param string $url - * @param array $data + * @param string $url + * @param array $data * @return mixed */ public function httpPostJson(string $url, array $query = [], array $json = []) @@ -71,7 +69,7 @@ class Client extends Request /** * Http get redirect. * - * @param string $url + * @param string $url * @return mixed */ public function httpGetRedirect(string $url) @@ -86,25 +84,25 @@ class Client extends Request /** * Http Post Upload video for mp4. * - * @param string $url - * @param array $query - * @param string $video_path + * @param string $url + * @param array $query + * @param string $video_path * @return mixed */ public function httpPostUpload($url, string $open_id, string $access_token, string $video_path) { $options = [ 'headers' => [ - 'access-token' => $access_token + 'access-token' => $access_token, ], 'multipart' => [ [ 'name' => 'video', - 'contents' => fopen($video_path, 'r') - ] - ] + 'contents' => fopen($video_path, 'r'), + ], + ], ]; - return $this->request($url . '?open_id=' . $open_id, 'POST', $options); + return $this->request($url.'?open_id='.$open_id, 'POST', $options); } } diff --git a/src/Kernel/Http/Request.php b/src/Kernel/Http/Request.php index f46541f68e7b35faa18d3778cae86341e7445715..2f8de438afbd649e9e7082040da59d48d905850a 100644 --- a/src/Kernel/Http/Request.php +++ b/src/Kernel/Http/Request.php @@ -54,7 +54,7 @@ class Request /** * init Options. * - * @param array $options + * @param array $options * @return array */ protected static function initOptions($options): array @@ -71,9 +71,9 @@ class Request /** * make request. * - * @param string $url - * @param string $method - * @param array $options + * @param string $url + * @param string $method + * @param array $options * @return \GuzzleHttp\Psr7\Response */ public function request($url, $method = 'GET', $options = [], $returnRaw = false): Response diff --git a/src/Kernel/Support/AES.php b/src/Kernel/Support/AES.php index 45011236bc1622ebe815f2547e8fe6e660aa4d14..83b7141a5e872257125647f14e4e318ddfad2ab6 100644 --- a/src/Kernel/Support/AES.php +++ b/src/Kernel/Support/AES.php @@ -18,7 +18,7 @@ class AES } /** - * @param string|null $method + * @param string|null $method */ public static function decrypt(string $cipherText, string $key, string $iv, int $option = OPENSSL_RAW_DATA, $method = null): string { @@ -29,18 +29,17 @@ class AES } /** - * @param string $key - * + * @param string $key * @return string */ public static function getMode($key) { - return 'aes-' . (8 * strlen($key)) . '-cbc'; + return 'aes-'.(8 * strlen($key)).'-cbc'; } public static function validateKey(string $key) { - if (!in_array(strlen($key), [16, 24, 32], true)) { + if (! in_array(strlen($key), [16, 24, 32], true)) { throw new \InvalidArgumentException(sprintf('Key length must be 16, 24, or 32 bytes; got key len (%s).', strlen($key))); } } @@ -50,7 +49,7 @@ class AES */ public static function validateIv(string $iv) { - if (!empty($iv) && 16 !== strlen($iv)) { + if (! empty($iv) && 16 !== strlen($iv)) { throw new \InvalidArgumentException('IV length must be 16 bytes.'); } } diff --git a/src/Kernel/Support/File.php b/src/Kernel/Support/File.php index 179ed1c181fc9df9029fb5960365e5ec513aa5f0..9e69ed42046a4e6a4af4d4374f5c922acd17769f 100644 --- a/src/Kernel/Support/File.php +++ b/src/Kernel/Support/File.php @@ -34,8 +34,7 @@ class File /** * Get file extension by file header signature. * - * @param string $stream - * + * @param string $stream * @return string */ public static function getExtBySignature($stream) diff --git a/src/Microapp/Application.php b/src/Microapp/Application.php index ab3db2d2482e084e8bef6c841bcb4ba207dfc68e..03899c926db1360253d313ac75e785fc034e692a 100644 --- a/src/Microapp/Application.php +++ b/src/Microapp/Application.php @@ -22,9 +22,8 @@ class Application extends ServiceContainer /** * Handle dynamic calls. * - * @param string $method - * @param array $args - * + * @param string $method + * @param array $args * @return mixed */ public function __call($method, $args) diff --git a/src/Microapp/Auth/AccessToken.php b/src/Microapp/Auth/AccessToken.php index 799f0ec812e465b28ffbd08fd7cd06090f9d420f..9f2aed705255126ecc5d026d83a2c835da2cef9c 100644 --- a/src/Microapp/Auth/AccessToken.php +++ b/src/Microapp/Auth/AccessToken.php @@ -12,7 +12,6 @@ namespace Codeinfo\LaravelBytedance\Microapp\Auth; use Codeinfo\LaravelBytedance\Kernel\Client; -use Codeinfo\LaravelBytedance\Kernel\Exceptions\Exception; use Codeinfo\LaravelBytedance\Kernel\Exceptions\InvalidArgumentException; use Codeinfo\LaravelBytedance\Kernel\Support\AES; use Illuminate\Support\Arr; @@ -93,7 +92,7 @@ class AccessToken extends Client */ private function getAccessToken() { - return Cache::remember($this->cachePrefix . 'access_token', 7200, $this->getToken()); + return Cache::remember($this->cachePrefix.'access_token', 7200, $this->getToken()); } /** @@ -126,7 +125,8 @@ class AccessToken extends Client } /** - * 解密敏感数据 + * 解密敏感数据. + * * @param string $encryptedData * @param string $sessionKey * @param string $iv diff --git a/src/Platform/Account/Account.php b/src/Platform/Account/Account.php index e971e9777f93d9125d21b441ce01a8de488f85d8..9f6f8d6d43ae0d5faeb23ce17fdf260ae18f21fc 100644 --- a/src/Platform/Account/Account.php +++ b/src/Platform/Account/Account.php @@ -20,8 +20,8 @@ class Account extends Client /** * 获取用户信息. * - * @param string $open_id - * @param string $access_token token每个用户一个 + * @param string $open_id + * @param string $access_token token每个用户一个 * @return array */ public function userInfo(string $open_id, string $access_token) @@ -39,7 +39,7 @@ class Account extends Client /** * 解密手机号. * - * @param string $string + * @param string $string * @return string */ public function decryptMobile(string $string) diff --git a/src/Platform/Application.php b/src/Platform/Application.php index f926e7e3244f170428afffbfe786c87e93652bf1..41edfccdaedc11903a50748448707c641d89f4e8 100644 --- a/src/Platform/Application.php +++ b/src/Platform/Application.php @@ -23,15 +23,14 @@ class Application extends ServiceContainer Ticket\ServiceProvider::class, Data\ServiceProvider::class, Life\ServiceProvider::class, - Hudong\ServiceProvider::class + Hudong\ServiceProvider::class, ]; /** * Handle dynamic calls. * - * @param string $method - * @param array $args - * + * @param string $method + * @param array $args * @return mixed */ public function __call($method, $args) diff --git a/src/Platform/Data/Data.php b/src/Platform/Data/Data.php index e531b3224d125839546ea182896f93525ffd125f..784534616dd493ae927a7293b18c32887701baf7 100644 --- a/src/Platform/Data/Data.php +++ b/src/Platform/Data/Data.php @@ -6,10 +6,8 @@ use Codeinfo\LaravelBytedance\Kernel\Client; class Data extends Client { - protected $baseUri = 'https://open.douyin.com'; - public function topic($access_token) { $response = $this->httpGet('/data/extern/billboard/topic/', [], ['access-token' => $access_token]); diff --git a/src/Platform/Hudong/Hudong.php b/src/Platform/Hudong/Hudong.php index d26447b7b9d1c43e88adca733fdea7e8e0a49cb8..a61817f79a2f162712481ecfbbcc08af7ab7e49f 100644 --- a/src/Platform/Hudong/Hudong.php +++ b/src/Platform/Hudong/Hudong.php @@ -3,7 +3,6 @@ namespace Codeinfo\LaravelBytedance\Platform\Hudong; use Codeinfo\LaravelBytedance\Kernel\Client; -use Codeinfo\LaravelBytedance\Kernel\ServiceContainer; class Hudong extends Client { @@ -11,26 +10,28 @@ class Hudong extends Client /** * 发送私信 - * @param $open_id [企业号open_id] - * @param $access_token [企业号token] - * @param $params + * + * @param $open_id [企业号open_id] + * @param $access_token [企业号token] + * @param $params * @return mixed */ public function sendMsg($open_id, $access_token, $params) { - $response = $this->httpPost('/im/send/msg/?open_id=' . $open_id, $params, ['access-token' => $access_token, 'Content-Type' => 'application/json']); + $response = $this->httpPost('/im/send/msg/?open_id='.$open_id, $params, ['access-token' => $access_token, 'Content-Type' => 'application/json']); return json_decode($response->getBody()->getContents(), true); } /** - * 回复视频评论 - * @param $open_id - * @param $access_token - * @param $params + * 回复视频评论. + * + * @param $open_id + * @param $access_token + * @param $params */ public function commentReply($open_id, $access_token, $params) { - $response = $this->httpPost('/item/comment/reply/?open_id=' . $open_id, $params, ['access-token' => $access_token, 'Content-Type' => 'application/json']); + $response = $this->httpPost('/item/comment/reply/?open_id='.$open_id, $params, ['access-token' => $access_token, 'Content-Type' => 'application/json']); } } diff --git a/src/Platform/Image/Image.php b/src/Platform/Image/Image.php index 9584f11376f608619f7f6becb0c91c3f3717a5f1..cb2ac32c4e5f9fe1cea45b63d8df66a15b3db7e2 100644 --- a/src/Platform/Image/Image.php +++ b/src/Platform/Image/Image.php @@ -6,11 +6,9 @@ use Codeinfo\LaravelBytedance\Kernel\Client; class Image extends Client { + protected $baseUri = 'https://open.douyin.com'; - protected $baseUri = 'https://open.douyin.com'; - - - public function upload(string $open_id, string $access_token, string $image_path) + public function upload(string $open_id, string $access_token, string $image_path) { $response = $this->httpPostUpload('/image/upload/', [ 'open_id' => $open_id, diff --git a/src/Platform/Life/Life.php b/src/Platform/Life/Life.php index f160bd64ecc643e302ad5f9f75e9cf52cbe1a2c9..dde3b486cd90eecee3188ba79edaf20f4d00dccc 100644 --- a/src/Platform/Life/Life.php +++ b/src/Platform/Life/Life.php @@ -4,7 +4,6 @@ namespace Codeinfo\LaravelBytedance\Platform\Life; use Codeinfo\LaravelBytedance\Kernel\Client; use Codeinfo\LaravelBytedance\Kernel\ServiceContainer; -use Illuminate\Support\Facades\Cache; class Life extends Client { @@ -20,9 +19,10 @@ class Life extends Client } /** - * 订单 - * @param $access_token - * @param array $params + * 订单. + * + * @param $access_token + * @param array $params * @return mixed */ public function orderQuery(array $params) @@ -33,9 +33,10 @@ class Life extends Client } /** - * 验券历史查询 - * @param $access_token - * @param array $params + * 验券历史查询. + * + * @param $access_token + * @param array $params * @return mixed */ public function verifyRecord(array $params) @@ -46,9 +47,10 @@ class Life extends Client } /** - * 分账明细查询 - * @param $access_token - * @param array $params + * 分账明细查询. + * + * @param $access_token + * @param array $params * @return mixed */ public function queryRecordByCert(array $params) @@ -59,8 +61,9 @@ class Life extends Client } /** - * 商品线上数据列表 - * @param array $params + * 商品线上数据列表. + * + * @param array $params * @return mixed */ public function goodsList(array $params) @@ -71,8 +74,9 @@ class Life extends Client } /** - * 查询商品线上数据 - * @param array $params + * 查询商品线上数据. + * + * @param array $params * @return mixed */ public function productOnlineGet(array $params) @@ -83,7 +87,8 @@ class Life extends Client } /** - * 上下架 + * 上下架. + * * @return mixed */ public function goodsProductOperate($params) @@ -101,7 +106,8 @@ class Life extends Client } /** - * 查询商品品类 + * 查询商品品类. + * * @return mixed */ public function goodsCategory($params) @@ -112,8 +118,9 @@ class Life extends Client } /** - * 门店信息查询 - * @param $params + * 门店信息查询. + * + * @param $params * @return mixed */ public function shopPoi($params) @@ -124,8 +131,9 @@ class Life extends Client } /** - * 创建/修改团购活动 - * @param $params + * 创建/修改团购活动. + * + * @param $params * @return mixed */ public function goodsProductSave($params) @@ -137,7 +145,8 @@ class Life extends Client /** * 免审修改商品 - * @param $params + * + * @param $params * @return mixed */ public function goodsProductFreeAudit($params) @@ -157,8 +166,9 @@ class Life extends Client //代运营相关 /** - * 合作列表获取 - * @param array $params + * 合作列表获取. + * + * @param array $params * @return mixed */ public function partnerOrderList(array $params) @@ -169,8 +179,9 @@ class Life extends Client } /** - * 同步库存 - * @param $params + * 同步库存. + * + * @param $params * @return mixed */ public function goodsStockSync($params) @@ -181,8 +192,9 @@ class Life extends Client } /** - * 合作详情查询 - * @param array $params + * 合作详情查询. + * + * @param array $params * @return mixed */ public function partnerOrderGet(array $params) @@ -193,8 +205,9 @@ class Life extends Client } /** - * 创建合作关系 - * @param $params + * 创建合作关系. + * + * @param $params * @return mixed */ public function partnerOrderCreate($params) @@ -205,8 +218,9 @@ class Life extends Client } /** - * 创建/修改佣金 - * @param $params + * 创建/修改佣金. + * + * @param $params * @return mixed */ public function partnerProductCommission($params) @@ -217,8 +231,9 @@ class Life extends Client } /** - * 佣金变更记录列表 - * @param $params + * 佣金变更记录列表. + * + * @param $params * @return mixed */ public function partnerCommissionRecordQuery($params) @@ -229,8 +244,9 @@ class Life extends Client } /** - * 佣金变更记录详情 - * @param $params + * 佣金变更记录详情. + * + * @param $params * @return mixed */ public function partnerCommissionRecordGet($params) @@ -241,8 +257,9 @@ class Life extends Client } /** - * 商品佣金详情 - * @param $params + * 商品佣金详情. + * + * @param $params * @return mixed */ public function partnerProductCommissionQuery($params) @@ -254,7 +271,8 @@ class Life extends Client /** * 发起店铺匹配 POI 同步任务 - * @param $params + * + * @param $params * @return mixed */ public function poiSupplierMatch($params) @@ -265,8 +283,9 @@ class Life extends Client } /** - * 店铺匹配任务结果查询 - * @param $params + * 店铺匹配任务结果查询. + * + * @param $params * @return mixed */ public function poiSupplierQueryTask($params) @@ -277,8 +296,9 @@ class Life extends Client } /** - * 商铺同步 - * @param $params + * 商铺同步. + * + * @param $params * @return mixed */ public function poiSupplierSync($params) diff --git a/src/Platform/Life/ServiceProvider.php b/src/Platform/Life/ServiceProvider.php index 05a3d9ecfc3603845df85f2f10ae1fd91c0ff88b..81a2444b0b1d8576eceebf372c15065ffccc902a 100644 --- a/src/Platform/Life/ServiceProvider.php +++ b/src/Platform/Life/ServiceProvider.php @@ -1,8 +1,8 @@ $scope, 'redirect_uri' => $redirect_uri, ]; - if (!blank($state)) { + if (! blank($state)) { $query['state'] = $state; } - $url = $this->baseUri . '/platform/oauth/connect/?'; + $url = $this->baseUri.'/platform/oauth/connect/?'; foreach ($query as $key => $value) { - $url .= '&' . $key . '=' . $value; + $url .= '&'.$key.'='.$value; } return $url; @@ -50,8 +50,8 @@ class Oauth extends Client /** * 生成用户静默授权地址 * - * @param string $redirect_uri - * @param string|null $state + * @param string $redirect_uri + * @param string|null $state * @return string */ public function genrateBaseUrl(string $redirect_uri, string $state = null) @@ -67,7 +67,7 @@ class Oauth extends Client $url = 'https://aweme.snssdk.com/oauth/authorize/v2/?'; foreach ($query as $key => $value) { - $url .= '&' . $key . '=' . $value; + $url .= '&'.$key.'='.$value; } return $url; @@ -76,7 +76,7 @@ class Oauth extends Client /** * 获取用户授权token. * - * @param string $code + * @param string $code * @return array */ public function getAccessToken(string $code) @@ -94,8 +94,9 @@ class Oauth extends Client } /** - * 刷新用户token - * @param string $refresh_token + * 刷新用户token. + * + * @param string $refresh_token * @return mixed */ public function refreshToken(string $refresh_token) @@ -103,7 +104,7 @@ class Oauth extends Client $query = [ 'client_key' => $this->app['config']['client_key'], 'grant_type' => 'refresh_token', - 'refresh_token' => $refresh_token + 'refresh_token' => $refresh_token, ]; $response = $this->httpGet('/oauth/refresh_token/', $query); @@ -112,15 +113,16 @@ class Oauth extends Client } /** - * 刷新用户 refresh_token - * @param string $refresh_token + * 刷新用户 refresh_token. + * + * @param string $refresh_token * @return mixed */ public function renewRefreshToken(string $refresh_token) { $query = [ 'client_key' => $this->app['config']['client_key'], - 'refresh_token' => $refresh_token + 'refresh_token' => $refresh_token, ]; $response = $this->httpGet('/oauth/renew_refresh_token/', $query); @@ -147,7 +149,8 @@ class Oauth extends Client $data = json_decode($response->getBody()->getContents(), true); - $accessToken = $data['data']['access_token']; + $accessToken = $data['data']['access_token']; + // }); // return $accessToken; diff --git a/src/Platform/Ticket/ServiceProvider.php b/src/Platform/Ticket/ServiceProvider.php index 3f176427f4a007c44064231f84d065e01a036c96..ffc00df0263f7bd8c23e806fb21abeb6434c876c 100644 --- a/src/Platform/Ticket/ServiceProvider.php +++ b/src/Platform/Ticket/ServiceProvider.php @@ -5,7 +5,7 @@ namespace Codeinfo\LaravelBytedance\Platform\Ticket; use Codeinfo\LaravelBytedance\Kernel\Contracts\ServiceProviderInterface; use Illuminate\Container\Container; -class ServiceProvider implements ServiceProviderInterface +class ServiceProvider implements ServiceProviderInterface { /** * {@inheritdoc}. diff --git a/src/Platform/Ticket/Ticket.php b/src/Platform/Ticket/Ticket.php index f41fd31f53186da2aeeb5fff6c37588764940f86..fb3a4cddace21343f68788dc787a41d119357020 100644 --- a/src/Platform/Ticket/Ticket.php +++ b/src/Platform/Ticket/Ticket.php @@ -15,7 +15,6 @@ class Ticket extends Client return json_decode($response->getBody()->getContents(), true); } - public function getJsTicket($access_token) { $response = $this->httpGet('/js/getticket/', [], ['access-token' => $access_token]); diff --git a/src/Platform/Video/Video.php b/src/Platform/Video/Video.php index 4e492af9343e5a16343c7d7837b81c45062aaabc..7c563960b15703499bfbbaa73535382506e22297 100644 --- a/src/Platform/Video/Video.php +++ b/src/Platform/Video/Video.php @@ -20,9 +20,9 @@ class Video extends Client /** * Upload Video. * - * @param string $open_id - * @param string $access_token - * @param string $video_path + * @param string $open_id + * @param string $access_token + * @param string $video_path * @return array */ public function upload(string $open_id, string $access_token, string $video_path) @@ -35,19 +35,19 @@ class Video extends Client /** * Video Create. * - * @param string $open_id - * @param string $access_token - * @param array $form_params + * @param string $open_id + * @param string $access_token + * @param array $form_params * @return array */ public function create(string $open_id, string $access_token, array $form_params) { $response = $this->httpPost( - 'https://open.douyin.com/api/douyin/v1/video/create_video/?open_id=' . $open_id, + 'https://open.douyin.com/api/douyin/v1/video/create_video/?open_id='.$open_id, $form_params, [ 'access-token' => $access_token, - 'content-type' => 'application/json' + 'content-type' => 'application/json', ] ); @@ -57,11 +57,11 @@ class Video extends Client /** * Video Comment. * - * @param string $open_id - * @param string $access_token - * @param string $content - * @param string $item_id - * @param string $comment_id + * @param string $open_id + * @param string $access_token + * @param string $content + * @param string $item_id + * @param string $comment_id * @return array */ public function comment( @@ -76,7 +76,7 @@ class Video extends Client 'content' => $content, ]; - if (!empty($comment_id)) { // 需要回复的评论id(如果需要回复的是视频不传此字段) + if (! empty($comment_id)) { // 需要回复的评论id(如果需要回复的是视频不传此字段) array_merge($form_params, [ 'comment_id' => $comment_id, ]); @@ -93,9 +93,9 @@ class Video extends Client /** * Query Video Information. * - * @param string $open_id - * @param string $access_token - * @param array $item_ids + * @param string $open_id + * @param string $access_token + * @param array $item_ids * @return array */ public function data(string $open_id, string $access_token, array $item_ids)