From ee8281dd06c5e8bb50ba987cbed9e43c7ac14b00 Mon Sep 17 00:00:00 2001 From: hide_d Date: Tue, 13 Mar 2018 19:43:10 +0900 Subject: [PATCH] =?UTF-8?q?=EC=B9=B4=EC=B9=B4=EC=98=A4=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=EC=83=81=EC=88=98=20GET,POST,DELETE=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmp_kakao/kakao.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tmp_kakao/kakao.php b/tmp_kakao/kakao.php index f3c4b864..76b42044 100644 --- a/tmp_kakao/kakao.php +++ b/tmp_kakao/kakao.php @@ -3,11 +3,6 @@ require(__DIR__.'/conf.php'); //https://devtalk.kakao.com/t/php-rest-api/14602/3 //header('Content-Type: application/json; charset=utf-8'); -define('GET', 'GET'); -define('POST', 'POST'); -define('DELETE', 'DELETE'); - - /////////////////////////////////////////////////////////////////////////////// @@ -80,7 +75,7 @@ class Kakao_REST_API_Helper ); } - public function request($api_path, $params = '', $http_method = GET) + public function request($api_path, $params = '', $http_method = 'GET') { if ($api_path != Story_Path::$UPLOAD_MULTI && is_array($params)) { // except for uploading $params = http_build_query($params); @@ -88,7 +83,7 @@ class Kakao_REST_API_Helper $requestUrl = ($api_path == '/oauth/token' ? self::$OAUTH_HOST : self::$API_HOST) . $api_path; - if (($http_method == GET || $http_method == DELETE) && !empty($params)) { + if (($http_method == 'GET' || $http_method == 'DELETE') && !empty($params)) { $requestUrl .= '?'.$params; } @@ -120,13 +115,13 @@ class Kakao_REST_API_Helper $opts[CURLOPT_HTTPHEADER] = $headers; } - if ($http_method == POST) { + if ($http_method == 'POST') { $opts[CURLOPT_POST] = true; if ($params) { $opts[CURLOPT_POSTFIELDS] = $params; } - } else if ($http_method == DELETE) { - $opts[CURLOPT_CUSTOMREQUEST] = DELETE; + } else if ($http_method == 'DELETE') { + $opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; } $curl_session = curl_init(); @@ -156,7 +151,7 @@ class Kakao_REST_API_Helper /////////////////////////////////////////////////////////////// private function _create_or_refresh_access_token($params) { - return $this->request(User_Management_Path::$TOKEN, $params, POST); + return $this->request(User_Management_Path::$TOKEN, $params, 'POST'); } public function create_access_token($authorization_code){ @@ -208,7 +203,7 @@ class Kakao_REST_API_Helper } public function update_profile($params) { - return $this->request(User_Management_Path::$UPDATE_PROFILE, $params, POST); + return $this->request(User_Management_Path::$UPDATE_PROFILE, $params, 'POST'); } public function user_ids() {