Getting vine thumbnail

1.1k Views Asked by At

I often try some code in online php editor so I don't have to upload files to my server or check it offline in browser.

I have this code that works in online editor:

   function get_vine_thumbnail( $id )
{
  $vine = file_get_contents("http://vine.co/v/{$id}");
    preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);

    return ($matches[1]) ? $matches[1] : false;
}

 $vine = "OBWu9Mmmujm";

echo get_vine_thumbnail($vine);

But when I upload it to my server it doesn't work anymore. Of course this shows only link to thumbnail. Anyone know what is the problem?

EDIT-SOLUTION: Go to your web hosting control panel, go to CGI and Scripted Language Support, select PHP Scripting and change allow_url_fopen = Off to allow_url_fopen = On.

1

There are 1 best solutions below

2
On BEST ANSWER

It seems to work fine

   function get_vine_thumbnail( $id )
{
  $vine = file_get_contents("http://vine.co/v/{$id}");
    preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);

    return ($matches[1]) ? $matches[1] : false;
}

 $vine = "OBWu9Mmmujm";

echo '<img src="'.get_vine_thumbnail($vine).'"/>';