doudouba4520 2018-10-23 17:24
浏览 65

Vimeo API获取结果为空的请求

On the playground I get 100 results for https://api.vimeo.com/me/videos. In my app, running the same GET request, I get an empty result.

I'm authenticating using Authorization: Bearer <PRIVATE ACCESS TOKEN> in the header.

public static function headers($post = false)
{
    $headers = array
    (
        'Authorization: Bearer '.self::myToken(),
        'Accept: application/json',
        'Cache-Control: no-cache',
    );
    if($post) $headers[] = 'Content-Type: application/json';
    return $headers;
}
public static function get($url = '')
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_HTTPHEADER, self::headers());
    curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
    curl_setopt($curl, CURLOPT_MAXREDIRS, 10);
    curl_setopt($curl, CURLOPT_ENCODING, "");
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
    $result = curl_exec($curl);
    $curl_info = curl_getinfo($curl);
    $error = curl_errno($curl);
    curl_close($curl);
    return $error 
        ? array('status'=>'error','message'=>$error) 
        : array('status'=>'success','result'=>json_decode($result,true));
}
print_r(self::get('https://api.vimeo.com/me/videos'));

If I don't include the auth token, I do get a result with an error about not having credentials. But when including the auth token, I get an empty response.

Again, in the API Playground, I get 100 videos in the result. What am I missing here? (The auth token is correct.)

All my videos are private, and the access token I'm using (the only one I've generated for my app) has full permissions, including private.

  • 写回答

1条回答 默认 最新

  • duanba8173 2018-10-23 17:38
    关注

    Q: Did you make sure that your myToken function isn't decrypting your token before returning it? And if it is, are you storing your token encrypted in the first place?

    A: No, I did not. No, I was not.

    For posterity, the above is an example of a working API request, so long as you pass it the token correctly.

    评论

报告相同问题?

悬赏问题

  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。