From 04d05c076a94e674270341aba4f50e0008e145bf Mon Sep 17 00:00:00 2001 From: Jeremy Lichtman Date: Thu, 21 Nov 2019 19:24:43 -0500 Subject: [PATCH] Absolute url --- src/Vimeo/Vimeo.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Vimeo/Vimeo.php b/src/Vimeo/Vimeo.php index 8a71941..09d96d7 100644 --- a/src/Vimeo/Vimeo.php +++ b/src/Vimeo/Vimeo.php @@ -85,7 +85,7 @@ public function __construct(string $client_id, string $client_secret, string $ac * @return array This array contains three keys, 'status' is the status code, 'body' is an object representation of the json response body, and headers are an associated array of response headers * @throws VimeoRequestException */ - public function request($url, $params = array(), $method = 'GET', $json_body = true, array $headers = array()): array + public function request($url, $params = array(), $method = 'GET', $json_body = true, array $headers = array(), $absolute_url = FALSE): array { $headers = array_merge(array( 'Accept' => self::VERSION_STRING, @@ -115,7 +115,12 @@ public function request($url, $params = array(), $method = 'GET', $json_body = t $query_component = ''; } - $curl_url = self::ROOT_ENDPOINT . $url . $query_component; + if (!$absolute_url) { + $curl_url = self::ROOT_ENDPOINT . $url . $query_component; + } + else { + $curl_url = $url . $query_component; + } break; case 'POST': @@ -125,11 +130,19 @@ public function request($url, $params = array(), $method = 'GET', $json_body = t if ($json_body && !empty($params)) { $headers['Content-Type'] = 'application/json'; $body = json_encode($params); + } else if ($absolute_url) { + // i.e. for putting a thumbnail image. + $body = $params[0]; } else { $body = http_build_query($params, '', '&'); } - $curl_url = self::ROOT_ENDPOINT . $url; + if (!$absolute_url) { + $curl_url = self::ROOT_ENDPOINT . $url; + } + else { + $curl_url = $url; + } $curl_opts = array( CURLOPT_POST => true, CURLOPT_CUSTOMREQUEST => $method,