Search code examples
phpvimeovimeo-api

Updating Vimeo Video information using API not working


I am using PHP API (https://github.com/vimeo/vimeo.php) to update the vimeo video information, but I am getting the following error: The requested video could not be found.

The code I used:

$video_response = $lib->request('/videos/$video_id', array('name' => ' TESTING'), 'PATCH');

Some insights:

  • The video is uploaded to private, only accessible to me. Although making that video public didn't change the results.
  • The video is uploaded via the API, using pull method. While trying to edit the information with that same app used to upload didn't work and returned that error message.
  • When tried on API playground (https://developer.vimeo.com/api/playground/videos/%7Bvideo_id%7D), I got the same results while trying with the app used to upload, but when I tried it with Authenticate this call as {MY USERNAME} option checked, it worked.

Solution

  • I believe in PHP, single quotes will not parse the variable.

    So the following:

    $video_id = 12345;
    $video_response = $lib->request('/videos/$video_id', array('name' => ' TESTING'), 'PATCH');
    

    Will make an HTTP POST request to https://api.vimeo.com/videos/$video_id

    You need to switch to double quotes, or string concatenation.

    $video_id = 12345;
    $video_response = $lib->request('/videos/' . $video_id, array('name' => ' TESTING'), 'PATCH');
    // OR
    $video_response = $lib->request("/videos/$video_id", array('name' => ' TESTING'), 'PATCH');
    

    Either of the above will make a Will make an HTTP POST request to https://api.vimeo.com/videos/12345