Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/Vimeo/Vimeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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':
Expand All @@ -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,
Expand Down