我正在尝试通过为Vine创建的oEmbed应用程序接口端点提取它们的JSON数据。这个请求在浏览器和我的本地Vagrant机器上都工作得很好,但是一旦我在服务器上运行它,它就抛出一个500 Internal server错误。这就好像我的Rackspace服务器被阻止向他们的API发出请求,但这是我第一次尝试向Vine发出请求。
$url = 'https://vine.co/oembed.json?url=http://vine.co/v/egXzgWMjrTj';
$res = file_get_contents($url);
$json = json_decode($res);我已经尝试使用cURL请求并将带有标头的stream_create_context()传入file_get_contents()调用。
我的示例cURL请求也返回HTML格式的500内部服务器错误
$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);我的最终目标是获得视频的缩略图,我正在对Vimeo和Instagram执行类似的请求,而不会收到内部服务器错误。
发布于 2015-08-15 01:19:06
这行得通,测试过了。
$res = file_get_contents('https://vine.co/oembed.json?url=http://vine.co/v/egXzgWMjrTj');
$json = json_decode($res,true);
echo $json['thumbnail_url'];将json_decode设置为true的第二个参数返回一个数组,而不是一个对象。
https://stackoverflow.com/questions/32015145
复制相似问题