naverWorker.php 수정
This commit is contained in:
@@ -5,13 +5,14 @@ namespace App\Libraries;
|
||||
class NaverApiClient
|
||||
{
|
||||
protected $baseUrl = 'https://test-b2b.land.naver.com';
|
||||
protected $charger = 'admin';
|
||||
protected $charger = '';
|
||||
|
||||
/**
|
||||
* [GET] 매물 정보 조회
|
||||
*/
|
||||
public function getArticleInfo(string $articleNumber): ?array
|
||||
{
|
||||
$this->charger = 'admin';
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-article/{$articleNumber}?charger={$this->charger}";
|
||||
|
||||
return $this->request('GET', $url);
|
||||
@@ -22,8 +23,9 @@ class NaverApiClient
|
||||
* @param string $articleNumber 매물번호
|
||||
* @param array $updateData 수정할 데이터 (tradeType, price, space 등)
|
||||
*/
|
||||
public function updateArticleInfo(string $articleNumber, array $updateData): ?array
|
||||
public function updateArticleInfo(string $articleNumber, array $updateData, string $charger = 'admin'): ?array
|
||||
{
|
||||
$this->charger = $charger;
|
||||
$url = "{$this->baseUrl}/kiso/center/verification-article/{$articleNumber}?charger={$this->charger}";
|
||||
|
||||
return $this->request('PUT', $url, $updateData);
|
||||
@@ -34,6 +36,11 @@ class NaverApiClient
|
||||
*/
|
||||
private function request(string $method, string $url, array $data = null): ?array
|
||||
{
|
||||
/**
|
||||
* curl --location 'https://test-b2b.land.naver.com/kiso/center/verification-article/2500000001?charger=admin' \
|
||||
--header 'X-Naver-Client-Id: yqBbvQZ123_hjH3b3Df9' \
|
||||
*/
|
||||
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
@@ -46,7 +53,23 @@ class NaverApiClient
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($payload)
|
||||
'Content-Length: ' . strlen($payload),
|
||||
'X-Naver-Client-Id: yqBbvQZ123_hjH3b3Df9'
|
||||
]);
|
||||
}
|
||||
} elseif ($method === 'GET') {
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'X-Naver-Client-Id: yqBbvQZ123_hjH3b3Df9'
|
||||
]);
|
||||
} elseif ($method === 'POST') {
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
if ($data) {
|
||||
$payload = json_encode($data);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen($payload),
|
||||
'X-Naver-Client-Id: yqBbvQZ123_hjH3b3Df9'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user