From 68cf8f2d793b6d1f2ecd3ea7e3cf4c30f8e82633 Mon Sep 17 00:00:00 2001 From: Lucas Delcroix Date: Tue, 14 Feb 2017 11:18:38 +0100 Subject: [PATCH 1/3] Rename File to fix autoload --- src/CALLR/API/Authentication/{ApiKey.php => ApiKeyAuth.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/CALLR/API/Authentication/{ApiKey.php => ApiKeyAuth.php} (100%) diff --git a/src/CALLR/API/Authentication/ApiKey.php b/src/CALLR/API/Authentication/ApiKeyAuth.php similarity index 100% rename from src/CALLR/API/Authentication/ApiKey.php rename to src/CALLR/API/Authentication/ApiKeyAuth.php From b0bbd2f55de9d91197e8973aa7c549c231b8d357 Mon Sep 17 00:00:00 2001 From: Lucas Delcroix Date: Tue, 14 Feb 2017 11:19:26 +0100 Subject: [PATCH 2/3] Change DEPRECATED message : you can't change the URL --- src/CALLR/API/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CALLR/API/Client.php b/src/CALLR/API/Client.php index dde4f76..990e83b 100644 --- a/src/CALLR/API/Client.php +++ b/src/CALLR/API/Client.php @@ -30,7 +30,7 @@ class Client */ public function setURL($url) { - trigger_error('setURL is deprecated. Do not change the URL (or extend client to be able to do so)', E_USER_DEPRECATED); + trigger_error('setURL is deprecated. Do not change the URL', E_USER_DEPRECATED); $this->url = $url; } From 18c6d6711f8d8a84203f3efd11117c353937949b Mon Sep 17 00:00:00 2001 From: Lucas Delcroix Date: Tue, 14 Feb 2017 11:20:41 +0100 Subject: [PATCH 3/3] Change headers before applying curl options --- src/CALLR/API/Request.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CALLR/API/Request.php b/src/CALLR/API/Request.php index 5c40360..6e8c794 100644 --- a/src/CALLR/API/Request.php +++ b/src/CALLR/API/Request.php @@ -47,21 +47,21 @@ public function send( /* curl */ $c = curl_init($url); - curl_setopt($c, CURLOPT_RETURNTRANSFER, true); - curl_setopt($c, CURLOPT_FAILONERROR, true); - curl_setopt($c, CURLOPT_HTTPHEADER, $headers); - curl_setopt($c, CURLOPT_POST, true); - curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($request)); - curl_setopt($c, CURLOPT_FORBID_REUSE, false); - if ($auth instanceof AuthenticationInterface) { - $headers += array_values($auth->getHeaders()); + $headers = array_merge($headers, array_values($auth->getHeaders())); $auth->applyCurlOptions($c); } elseif (!empty($auth)) { trigger_error('Using a string for auth is deprecated, use a proper Authenticator instead', E_USER_DEPRECATED); curl_setopt($c, CURLOPT_USERPWD, $auth); } + curl_setopt($c, CURLOPT_RETURNTRANSFER, true); + curl_setopt($c, CURLOPT_FAILONERROR, true); + curl_setopt($c, CURLOPT_HTTPHEADER, $headers); + curl_setopt($c, CURLOPT_POST, true); + curl_setopt($c, CURLOPT_POSTFIELDS, json_encode($request)); + curl_setopt($c, CURLOPT_FORBID_REUSE, false); + if (is_string($proxy)) { curl_setopt($c, CURLOPT_PROXY, $proxy); }