33 lines
827 B
PHP
33 lines
827 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class LimanService
|
|
{
|
|
public function liman_login()
|
|
{
|
|
$config = app(ConfigService::class);
|
|
|
|
$mobile = $config->Config('liman_mobile');
|
|
$password = $config->Config('liman_password');
|
|
|
|
$liman = Http::timeout(10)->post('http://212.23.201.173/server/auth/login', [
|
|
'mobile' => $mobile,
|
|
'password' => $password,
|
|
'provider' => 'customer',
|
|
'type_app' => 'client',
|
|
])->json();
|
|
|
|
$token = $liman['access_token'] ?? $liman['token'] ?? null;
|
|
|
|
if (!$token) {
|
|
throw new \Exception('Liman login failed: ' . json_encode($liman, JSON_UNESCAPED_UNICODE));
|
|
}
|
|
|
|
$config->UpdateConfig('liman_token', $token);
|
|
|
|
return $token;
|
|
}
|
|
} |