Initial import from local backup (Documents-Playground/pakerpale)

This commit is contained in:
jeonghwa
2026-07-03 05:27:08 +09:00
commit c55f993072
1519 changed files with 374497 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
class AuthServiceClient
{
public function __construct()
{ }
private static function getToken($name)
{
$token = get_cookie($name);
if (empty($token)) {
AuthServiceClient::setToken();
}
$token = get_cookie($name);
return $token;
}
protected function getTokenFromCookie()
{
return AuthServiceClient::getToken('bs_token');
}
private static function setCookie($cookie)
{
return set_cookie($cookie);
}
public static function setToken()
{
$client = new Client();
try {
$response = $client->request('GET', API_GATEWAY_URI . '/oauth/token', [
'query' => [
'client_id' => 'F8Nbz9gGUvLgdn8T',
'grant_type' => 'client_credentials',
'client_secret' => 'Fesmx7hHCCMx7Cby7FhV2fAtf2NYEFzP5fCKuwEEdpf8hpnsnnQn9qYhNHt6SsDD',
'code' => 'a9c6380a-9e34-467f-a1ae-514bb51a7724',
'scope' => 'api'
],
'defaults' => ['verify' => false]
]);
$body = $response->getBody();
self::setCookieToken(json_decode($body));
} catch (\GuzzleHttp\Exception\ConnectException $e) {
error_log('Connection errir....');
error_log($e->getMessage()); exit();
} catch (ClientException $e) {
error_log($e->getMessage());
redirect('/sign/logout');
}
}
private static function setCookieToken($token)
{
self::setCookie([
'name' => 'token',
'value' => $token->access_token,
'expire' => '86500',
'domain' => $_SERVER['SERVER_NAME'],
'path' => '/',
'prefix' => 'bs_'
]);
self::setCookie([
'name' => 'token_expires',
'value' => $token->expires_in,
'expire' => '86500',
'domain' => $_SERVER['SERVER_NAME'],
'path' => '/',
'prefix' => 'bs_'
]);
}
}

View File

@@ -0,0 +1,25 @@
<?php
use GuzzleHttp\Client;
require_once __DIR__ . '/RestServiceClient.php';
class RestCoupangApiServiceClient extends RestServiceClient
{
public function __construct()
{ }
public function getCategory($categoryCode)
{
$response = $this->request('GET', '/coupang/category?categoryCode='. $categoryCode, []);
return $response->data;
}
public function postProduct($params) {
$response = $this->request('POST', '/coupang/product', $params);
return $response->data;
}
}

View File

@@ -0,0 +1,55 @@
<?php
use GuzzleHttp\Client;
require_once __DIR__ . '/RestServiceClient.php';
class RestCrawlerServiceClient extends RestServiceClient
{
public function __construct()
{ }
public function saveVideo($params)
{
$response = $this->request('POST', '/api/v1/video', $params);
return $response;
}
public function getProductByAsinCode($asinCode)
{
error_log('/amazon/product/detail/'. $asinCode);
$response = $this->request('GET', '/amazon/product/detail/'. $asinCode, []);
return $response;
}
public function getProductByBatchAsinCode($asinCode)
{
error_log('/amazon/product/detail/batch'. print_r($asinCode, true));
$response = $this->request('POST', '/amazon/product/detail/batch', $asinCode);
return $response;
}
public function getVideoCategory($params)
{
$response = $this->request('GET', '/api/v1/video/category', $params);
return $response->data;
}
public function saveVideoCategory($params)
{
$response = $this->request('POST', '/api/v1/video/category', $params);
return $response;
}
public function deleteVideo($params) {
$response = $this->request('DELETE', '/api/v1/video', $params);
return $response;
}
public function updateVideo($params) {
$response = $this->request('PUT', '/api/v1/video', $params);
return $response->data;
}
}

View File

@@ -0,0 +1,47 @@
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
require_once __DIR__ . '/AuthServiceClient.php';
class RestServiceClient extends AuthServiceClient
{
public function __construct()
{ }
protected function request($method, $url, $body)
{
$response = null;
$client = new Client();
$headers = [
'Authorization' => 'Bearer ' . $this->getTokenFromCookie(),
'Content-Type' => 'application/json'
];
error_log(sprintf("Request headers: %s", json_encode($headers)));
$request = new Request($method, API_GATEWAY_URI . $url, $headers, json_encode($body));
try {
$response = $client->send($request, ['timeout' => 20]);
} catch (Exception $e) {
error_log($e->getMessage());
}
if (is_null($response) || $response->getStatusCode() != 200) {
error_log(print_r($response, true));
redirect('/sign/logout');
} else if ($response) {
$body = $response->getBody();
$json = json_decode($body);
if($json->code != 200) {
if($json->code == 406) {
self::setToken();
redirect(uri_string());
}else {
error_log(print_r($json, true));
}
}
return $json;
}
}
}

View File

@@ -0,0 +1,21 @@
<?php
use GuzzleHttp\Client;
require_once __DIR__ . '/RestServiceClient.php';
class RestTaskCoupangServiceClient extends RestServiceClient
{
public function __construct()
{ }
public function getCategories()
{
$response = $this->request('GET', '/task/coupang/categories', []);
return $response->data;
}
}

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>