weizong song 2 days ago
parent 8fbdb9b91b
commit 6f7874d23c

@ -60,6 +60,10 @@ class VerifyQccEnterprisePackInfo extends Command
} catch (Throwable $exception) {
$this->error($exception->getMessage());
$this->line('签名 timestamp:' . ($yuanheRepository->lastRequestTimestamp ?? '(未生成)'));
if ($yuanheRepository->lastRequest) {
$this->line('完整请求入参(不含 authKey):');
$this->line(json_encode($yuanheRepository->lastRequest, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
}
if ($exception instanceof YuanhePackInfoException) {
$this->table(
['HTTP 状态', 'Content-Type', '响应字节数'],
@ -79,6 +83,8 @@ class VerifyQccEnterprisePackInfo extends Command
}
$freshAccount = $account->fresh();
$this->line('完整请求入参(不含 authKey):');
$this->line(json_encode($yuanheRepository->lastRequest, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
$this->line('签名 timestamp:' . ($yuanheRepository->lastRequestTimestamp ?? '(未生成)'));
$this->table(
['元禾 code', '元禾 msg', '调用后状态', '首次成功引用'],

@ -34,6 +34,8 @@ class VerifyYuanheEnterpriseSearch extends Command
}
$response = $result['response'];
$this->line('完整请求入参(不含 authKey):');
$this->line(json_encode($repository->lastRequest, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
$data = $response['data'] ?? null;
$this->line('签名 timestamp:' . ($repository->lastRequestTimestamp ?? '(未生成)'));
$this->table(

@ -17,6 +17,7 @@ class YuanheRepository
public $customerId;
public $authKey;
public $lastRequestTimestamp;
public $lastRequest;
public function __construct()
{
@ -89,7 +90,14 @@ class YuanheRepository
public function enterpriseSearchProbe(array $params): array
{
$url = $this->baseUrl . '/master-service/openapi/businessCollege/enterprise/search';
$rawResponse = httpCurl($url, 'GET', $params, $this->getHeader());
$headers = $this->getHeader();
$this->lastRequest = [
'method' => 'GET',
'url' => $url,
'query' => $params,
'headers' => $this->headersToMap($headers),
];
$rawResponse = httpCurl($url, 'GET', $params, $headers);
$response = json_decode($rawResponse, true);
return [
@ -109,6 +117,13 @@ class YuanheRepository
{
$url = $this->baseUrl . '/master-service/openapi/businessCollege/enterprise/packInfo';
$header = $this->getHeader();
$payload = json_encode($params, JSON_UNESCAPED_UNICODE);
$this->lastRequest = [
'method' => 'POST',
'url' => $url,
'json' => $params,
'headers' => $this->headersToMap($header),
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@ -117,7 +132,7 @@ class YuanheRepository
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params, JSON_UNESCAPED_UNICODE));
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
if (stripos($url, 'https://') !== false) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
@ -151,6 +166,17 @@ class YuanheRepository
return $result;
}
protected function headersToMap(array $headers): array
{
$mapped = [];
foreach ($headers as $header) {
[$name, $value] = array_pad(explode(':', $header, 2), 2, '');
$mapped[trim($name)] = trim($value);
}
return $mapped;
}
/**
* 数据推送
*/

Loading…
Cancel
Save