diff --git a/.gitignore b/.gitignore index 4250e71..7e97b19 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,4 @@ npm-debug.log yarn-error.log /.idea /.vscode -/tests/ /public/ diff --git a/tests/Feature/Afadian.php b/tests/Feature/Afadian.php new file mode 100644 index 0000000..3742cc4 --- /dev/null +++ b/tests/Feature/Afadian.php @@ -0,0 +1,55 @@ +get() + ->toArray(); + $userID = $result[20]->data; + $token = $result[21]->data; + $time = time(); + $params = [ + 'page' => 1, + 'per_page' => 50, + ]; + $sign = md5($token . 'params' . json_encode($params) . 'ts' . $time . 'user_id' . $userID); + + $data = [ + 'query' => [ + 'user_id' => $userID, + 'params' => json_encode($params), + 'ts' => $time, + 'sign' => $sign, + ], + ]; + + $client = new Client(['verify' => false]); + try { + $response = $client->get('https://afdian.net/api/open/query-sponsor', $data); + + var_dump(json_decode($response->getBody()->getContents())); + + + $this->assertTrue(true, "可以访问"); + } catch (GuzzleException $e) { + echo $e; + $this->fail("发生错误"); + } + } +} diff --git a/tests/Feature/NeteaseCloud.php b/tests/Feature/NeteaseCloud.php new file mode 100644 index 0000000..3720d72 --- /dev/null +++ b/tests/Feature/NeteaseCloud.php @@ -0,0 +1,40 @@ + [ + 'id' => '32459197', + 'limit' => 20, + ], + ]; + + $client = new Client(['verify' => false]); + try { + $response = $client->get('https://netease.api.x-lf.cn/artist/songs', $data); + + print_r(json_decode($response->getBody()->getContents())); + + + $this->assertTrue(true, "可以访问"); + } catch (GuzzleException $e) { + echo $e; + $this->fail("发生错误"); + } + } +}