diff --git a/backend/app/Command/AppCompanySync.php b/backend/app/Command/AppCompanySync.php index 254adb5..d97778f 100644 --- a/backend/app/Command/AppCompanySync.php +++ b/backend/app/Command/AppCompanySync.php @@ -7,6 +7,7 @@ namespace App\Command; use Hyperf\Command\Command as HyperfCommand; use Hyperf\Command\Annotation\Command; use Psr\Container\ContainerInterface; +use App\Platform\Tools\Request\CompanyRequest; #[Command] class AppCompanySync extends HyperfCommand @@ -24,7 +25,9 @@ class AppCompanySync extends HyperfCommand public function handle() { - $companies = + $companies = CompanyRequest::all(); + + dump($$companies); $this->line('Hello Hyperf!', 'info'); } diff --git a/backend/app/Platform/Tools/HttpClient.php b/backend/app/Platform/Tools/HttpClient.php index 1920f43..45afb5f 100644 --- a/backend/app/Platform/Tools/HttpClient.php +++ b/backend/app/Platform/Tools/HttpClient.php @@ -30,7 +30,7 @@ class HttpClient // 添加自动重试中间件 $stack->push(Middleware::retry(self::retryPolicy(), self::retryDelay())); - + $config = [ 'headers' => [ 'Accept' => 'application/json; charset=utf-8', @@ -41,7 +41,7 @@ class HttpClient 'connect_timeout' => 10, 'timeout' => 60, 'handler' => $stack, - 'debug' => false + 'debug' => true ]; return new Client($config); @@ -193,10 +193,11 @@ class HttpClient $http_code = $response->getStatusCode(); $body = $response->getBody(); + // dump($body->getContents()); // when deal with stream object, need to move to pointer to the ram head $body->rewind(); $content = $body->getContents(); - $payload = \json_decode($content); + $payload = \json_decode($content, 1); if ($http_code == 200) { return $payload; }