• Well, firstly hello to everybody this is my first post here.

    The case is that I am developing a plugin and is the first time that I work with the WP Http API.

    I want to get the thumbnail url of a Vimeo Video and right now I am trying with a snipt of the Codex that I converted in a function.

    function get_url_video($url = '') {
    
          $response = wp_remote_get($url);
    
             if(is_wp_error($response)) return 'Something went wrong!';
    
             else return $response;
    
    }

    If I put the url of direct way:

    $the_data = get_url_video('http://vimeo.com/api/v2/video/2251254.php');
    $data_body = unserialize($the_data['body']);
    echo $data_body[0]['thumbnail_large'];

    Everything works fine and I got that I want (The video url thumbnail).

    But if I retrieve the video ID with regex, I concatenate this to form the url and later I pass this to WP Remote Get nothing happens.

    $data_by_regex = array('domain', 2251254);
    $the_url = 'http://vimeo.com/​api/​v2/​video/' . $data_by_regex[1] . '.php';
    $the_data = get_url_video($the_url);
    $data_body = unserialize($the_data['body']);
    echo $data_body[0]['thumbnail_large'];

    I know that there are another ways of doing this but because is WP, I dont want to use CURL, file_get_content or another, I want to do this with the Http API so I hope someone help me to resolve this problem.

  • The topic ‘How to get Vimeo thumbnail with WP Http API’ is closed to new replies.