Vimeo的新API的方法遇到麻烦 [英] Having trouble with methods for Vimeo's new API

查看:85
本文介绍了Vimeo的新API的方法遇到麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用vimeo.videos.getInfo方法来获取有关上传到我的帐户的私人视频的信息。我只会在一个网站上使用此应用程序,因此我很难将访问令牌编码到代码中。

I'd like to use the method vimeo.videos.getInfo to get the info on a private video uploaded to my account. I'll only ever use this application on one website, so I'm hard coding the access token into the code.

我正在使用官方的PHP库Vimeo API( https://github.com/vimeo/vimeo.php )。

I'm using the official PHP library for the Vimeo API (https://github.com/vimeo/vimeo.php).

所以这就是我到目前为止所拥有的...

So here's what I have so far...

$vimeo = new Vimeo($apiKey, $apiSecret, $accessToken);

一切都很好。首先,当我尝试示例中的示例代码时:

All good. At first, when I tried the sample code from the example:

$user_data = $vimeo->request('/me');
print_r($user_data);

返回一个空数组:

Array (
    [body] => 
    [status] => 0
    [headers] => Array
        (
        )

)

我注意到他们提到了数组是否返回如果为空,则可能与无效的SSL证书有关。现在,我只是在localhost上进行开发,因此我将CURLOPT_SSL_VERIFYPEER设置为false(由于这些说明: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https -ssltls-protected-sites / )。我将其添加到vimeo.php的第112行的数组中:

I noticed they mentioned if the array is returning empty, it probably had something to do with an invalid SSL certificate. Right now, I'm just developing on localhost, so I set CURLOPT_SSL_VERIFYPEER to false (thanks to these instructions: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/). I added it to the array on line 112 in vimeo.php:

$curl_opt_defaults = array(
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_SSL_VERIFYPEER => false);

这样做后,我就可以返回有关已验证用户的信息。

As soon as I did that, I was able to return the information about the authenticated user.

但这仍然返回一个空数组:

But this still is returning an empty array:

$params = array(
    'video_id' => 95307197
);
$videos = $vimeo->request('vimeo.videos.getInfo', $params);
print_r($videos);

与我尝试放入的任何方法相同。我的CURLOPT_SSL_VERIFYPEER是做错了还是我的语法有其他问题?

Same with any methods I try to put in there. Did I do the CURLOPT_SSL_VERIFYPEER thing wrong or is something else wrong with my syntax?

推荐答案

希望这对其他人有帮助。 Vimeo API文档已不合时宜,新的API文档链接回旧的API文档,这只会增加混乱。

Hopefully this helps someone else. The Vimeo API documentation is all out of whack and the new API docs link back to the older API docs, which only adds to the confusion.

新的API没有使用高级API中的方法,它在此处使用端点 https://developer.vimeo.com/api/端点

The new API doesn't use the methods from the Advanced API, it uses the endpoints here https://developer.vimeo.com/api/endpoints

这是最终为我工作的代码:

Here is the code that eventually worked for me:

$videos = $vimeo->request("/videos/$video_id");
print_r($videos);

这篇关于Vimeo的新API的方法遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆