作者 赵彬吉

update

... ... @@ -10,6 +10,7 @@ use App\Models\Subscribe\Smtp;
use App\Models\Workchat\MessagePush;
use App\Services\Aside\ProjectAssociation\ProjectAssociationServices;
use Illuminate\Console\Command;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Mail;
... ... @@ -44,6 +45,8 @@ class WorkchatMessageSend extends Command
ProjectAssociationServices::getInstance()->sendMessage($task->friend_id, $task->content, $task->content_type);
$this->output('推送消息' . $task->id . '成功');
$task->status = MessagePush::STATUS_SUCCESS;
}catch (ConnectionException $e){
$this->output('推送消息' . $task->id . '超时');
}catch (\Exception $e){
$this->output('推送消息' . $task->id . '失败:' . $e->getMessage());
$task->status = MessagePush::STATUS_ERROR;
... ...
... ... @@ -168,14 +168,7 @@ class ProjectAssociationServices extends BaseService
}
$param['sign'] = $this->getSign($param);
$url = 'https://hub.ai.cc/api/globalso_ai_customer_service/chatroom_list';
// $result = Http::withoutVerifying()->post($url, $param)->json();
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', $url, [
'proxy' => env('CURL_PROXY'),
'json' => $param,
'verify' => false,
])->getBody()->getContents();
$result = json_decode($result, true);
$result = Http::withoutVerifying()->post($url, $param)->json();
if(empty($result) || $result['status'] != 200){
return [];
}
... ... @@ -196,17 +189,7 @@ class ProjectAssociationServices extends BaseService
];
$param['sign'] = $this->getSign($param);
$url = 'https://hub.ai.cc/api/globalso_ai_customer_service/send_msg';
// $result = Http::withoutVerifying()->post($url, $param)->json();
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', $url, [
'proxy' => env('CURL_PROXY'),
'json' => $param,
'verify' => false,
])->getBody()->getContents();
$result = json_decode($result, true);
$result = Http::withoutVerifying()->timeout(10)->post($url, $param)->json();
if(empty($result) || $result['status'] != 200){
throw new \Exception($result['message'] ?? '');
}
... ...