From 1c2c1ef0e20de0e8f64dfe79e50d1bf26860ab42 Mon Sep 17 00:00:00 2001 From: KOYAMA Tetsuji Date: Fri, 22 Oct 2021 18:20:46 +0900 Subject: [PATCH 1/3] fix: Use 'curl/curl' instead for 'alexsoft/curl' --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 32f70cc..4316f4a 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,11 @@ ], "require": { "php": ">=5.3.0", - "alexsoft/curl": "0.4.*@dev" + "curl/curl": "^2.3.2" }, "require-dev":{ "phpunit/phpunit":"3.7.*", - "mockery/mockery": "dev-master@dev" + "mockery/mockery": "*" }, "autoload": { "psr-0": { From ed2155c54cf84c3fc0e6dfd33e13c7bbef94af34 Mon Sep 17 00:00:00 2001 From: KOYAMA Tetsuji Date: Fri, 22 Oct 2021 18:22:18 +0900 Subject: [PATCH 2/3] fix: use Curl\Curl instead for Alexsoft\Curl. --- src/Asakusuma/SugarWrapper/Rest.php | 36 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/Asakusuma/SugarWrapper/Rest.php b/src/Asakusuma/SugarWrapper/Rest.php index 70a199d..aee8b60 100644 --- a/src/Asakusuma/SugarWrapper/Rest.php +++ b/src/Asakusuma/SugarWrapper/Rest.php @@ -2,7 +2,7 @@ namespace Asakusuma\SugarWrapper; -use \Alexsoft\Curl; +use \Curl\Curl; /** * SugarCRM REST API Class @@ -67,7 +67,7 @@ class Rest /** * The curl object we use to talk to the API * - * @var \Alexsoft\Curl + * @var \Curl\Curl */ private $request; @@ -254,10 +254,10 @@ private function login($md5_password = true) /** * Set a curl object, mainly used for testing * - * @param \Alexsoft\Curl $curl + * @param \Curl\Curl $curl * @return \Asakusuma\SugarWrapper\Rest */ - public function setCurl(\Alexsoft\Curl $curl) + public function setCurl(\Curl\Curl $curl) { $this->request = $curl; @@ -267,12 +267,12 @@ public function setCurl(\Alexsoft\Curl $curl) /** * Returns the curl object, or creates one * - * @return \Alexsoft\Curl + * @return \Curl\Curl */ public function getCurl() { if ($this->request === null) { - $this->request = new Curl($this->rest_url); + $this->request = new Curl(); } return $this->request; @@ -290,20 +290,18 @@ public function getCurl() private function rest_request($call_name, $call_arguments) { $request = $this->getCurl(); - $request->addData( - array( - 'method' => $call_name, - 'input_type' => 'JSON', - 'response_type' => 'JSON', - 'rest_data' => json_encode($call_arguments) - ) - ); - if($call_name == 'set_entry') { - $request->addHeaders(array('Expect'=>' ')); + if ($call_name == 'set_entry') { + $request->setHeader('Expect', ' '); } - - $output = $request->post(); - $response_data = json_decode(html_entity_decode($output['body']), true); + $request->post($this->rest_url, [ + 'method' => $call_name, + 'input_type' => 'JSON', + 'response_type' => 'JSON', + 'rest_data' => json_encode($call_arguments), + ]); + + $response_data = json_decode(html_entity_decode($request->response), true); + var_dump($response_data);exit; return $response_data; } From edba2cd0caf258038cf820b1894a7119480b5d89 Mon Sep 17 00:00:00 2001 From: KOYAMA Tetsuji Date: Fri, 22 Oct 2021 18:38:33 +0900 Subject: [PATCH 3/3] fix: remove debug dump. --- src/Asakusuma/SugarWrapper/Rest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Asakusuma/SugarWrapper/Rest.php b/src/Asakusuma/SugarWrapper/Rest.php index aee8b60..9c7f37d 100644 --- a/src/Asakusuma/SugarWrapper/Rest.php +++ b/src/Asakusuma/SugarWrapper/Rest.php @@ -301,8 +301,6 @@ private function rest_request($call_name, $call_arguments) ]); $response_data = json_decode(html_entity_decode($request->response), true); - var_dump($response_data);exit; - return $response_data; }