Skip to content
Advertisement

Vimeo API: cannot delete because official SDK is using a wrong url

Environment

  • Debian 9
  • PHP 7.2
  • Vimeo package version in composer.json: “vimeo/vimeo-api”: “^3.0.2”
    • resolved as version 3.0.2

The goal

Given a vimeo content url, delete the video. For example: having a video https://vimeo.com/12345678 I want to delete the video with the id 12345678

What I am doing

1. Instanciate the php sdk api client

$client = new Vimeo(
   config('dyamer.vimeo_client_id'),
   config('dyamer.vimeo_client_secret'),
   config('dyamer.vimeo_access_token')
);

This configs are right, I’m using to upload videos and all works

2. Call the delete api endpoint

$uri="https://vimeo.com/12345678";
$response = $client->request($uri, [], 'DELETE');

The exception

The last row of code is throwing an absurd exception:

[Could not resolve host: api.vimeo.comhttps] 
in /...project_folder.../vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php:527
Stack trace:
#0 /...project_folder.../vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php(149): VimeoVimeo->_request('https://api.vim...', Array)

The last row is litterally showed with url trunced, it’s not my fault on copy/pasting, but I think this demonstrate that something is wrong inside Vimeo SDK

Questions

  • Is it happening only to me?
  • Am I doing something wrong?
  • How can I circument this problem?

Side notes

I already opened an issue on Gihhub, without any official reply from sdk developers.

Advertisement

Answer

I succesfully traced the error to an error of mine

This is the incriminated snippet actually on github here

            case 'DELETE':
                if ($json_body && !empty($params)) {
                    $headers['Content-Type'] = 'application/json';
                    $body = json_encode($params);
                } else {
                    $body = http_build_query($params, '', '&');
                }
                $curl_url = self::ROOT_ENDPOINT . $url;
                $curl_opts = array(
                    CURLOPT_POST => true,
                    CURLOPT_CUSTOMREQUEST => $method,
                    CURLOPT_POSTFIELDS => $body
                );
                break;

Dumping the $curl_url I see

https://api.vimeo.comhttps://vimeo.com/12345678

Is is obviously wrong.

From official api doc about DELETE

REQUEST

DELETE https://api.vimeo.com/videos/{video_id}

So error is entirely mine

Wrong

$uri="https://vimeo.com/12345678";
$response = $client->request($uri, [], 'DELETE');

Right

$uri="videos/12345678";
$response = $client->request($uri, [], 'DELETE');

Sorry, Vimeo staff, it was my fault, not yours.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement