I am trying to pull the JSON data for a Vine via the oEmbed API endpoint created for them. The request works fine in the browser and on my local Vagrant machine, but as soon as I run it on the server, it throws a 500 Internal Server Error. It is as if my Rackspace server has been blocked from making requests to their API, but this is the first time I have ever attempted to make requests to Vine.
$url = 'https://vine.co/oembed.json?url=http://vine.co/v/egXzgWMjrTj';
$res = file_get_contents($url);
$json = json_decode($res);
I have already tried using a cURL request and passing in stream_create_context() with headers into the file_get_contents() call.
My example cURL request that is also returning HTML formatted 500 Internal Server Error
$url = 'https://vine.co/oembed.json?url=http://vine.co/v/egXzgWMjrTj';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
My ultimate goal is to get the thumbnail for the video and I am performing similar requests to Vimeo and Instagram without getting an Internal Server Error.
This works, Tested it.
The second parameter of json_decode to true returns an array instead of an object.