如何发出 API 请求以在 Objective-C 中获取私有 Vimeo 视频? [英] How to make API request to get private Vimeo videos in Objective-C?

查看:23
本文介绍了如何发出 API 请求以在 Objective-C 中获取私有 Vimeo 视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 iOS 应用程序来播放私人 Vimeo 视频.私人视频被赋予从 Vimeo 网站和指定域隐藏视频的隐私,以便这些视频只能在我的网站上购买和播放.我有 Vimeo PRO 帐户.

I'm developing an iOS application to play private Vimeo videos. Private videos are given privacy of hiding videos from Vimeo website and given domains so that those videos only will be bought and played in my websites. I have Vimeo PRO account.

我正在使用 VIMNetworking SDK 并通过使用我在 https:/上创建应用程序的客户端详细信息在 didFinishLaunchingWithOptions() 中进行身份验证/developer.vimeo.com/apps.

I am using VIMNetworking SDK and make authentication in didFinishLaunchingWithOptions() by using client details I got creating app at https://developer.vimeo.com/apps.

现在我必须发出 API 请求才能获得直接的视频网址.我不知道如何实现这一目标.Vimeo 没有提供 Objective-c 的文档.通过使用以下代码,我获得了公共视频响应,但不适用于私人视频.

Now I have to make API request to get direct video urls. I don't know how to achieve this. Vimeo doesn't give documentation for objective-c. By using below code I get public video response but not working for private videos.

 [[VIMSession sharedSession].client requestURI:@"/videos/4378389" completionBlock:^(VIMServerResponse *response, NSError *error) {        
        id JSONObject = response.result;
        NSLog(@"JSONObject: %@", JSONObject);
    }];

我什至尝试使用此代码来获取私人视频.但我得到了回应.

I even tried this code to get private videos. But I get in response.

 VIMClient *client = [[VIMClient alloc] initWithDefaultBaseURL];

    client.requestSerializer = [AFJSONRequestSerializer serializer];

    [client.requestSerializer setValue:@"application/vnd.vimeo.*+json; version=3.2" forHTTPHeaderField:@"Accept"];
     [client.requestSerializer setValue:@"my_client_id" forHTTPHeaderField:@"Authorization"];


    [client requestURI:@"https://api.vimeo.com/me/videos" completionBlock:^(VIMServerResponse *response, NSError *error)
    {

        id JSONObject = response.result;
        NSLog(@"JSONObject: %@", JSONObject);

    }];

还有获得这些错误的第三种方法:请求失败:未经授权(401)"和请求失败:不可接受的内容类型:application/vnd.vimeo.error+json".它的错误描述很长.

And there's the third way with getting these errors: "Request failed: unauthorized (401)" and "Request failed: unacceptable content-type: application/vnd.vimeo.error+json". Its a long error description.

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

NSDictionary *param = @{@"response_type" : @"code", @"client_id" : @"my_cleint_id", @"redirect_uri" : @"vimeo{my_cleint_id}://auth", @"state" : @"exercise"};

[manager GET:@"https://api.vimeo.com/me/videos" parameters:param success:^(AFHTTPRequestOperation *operation, id responseObject)
 {

     NSLog(@"Forgot Password JSON: %@",responseObject);


 }
      failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          NSLog(@"Error: %@", error.description);

      }];

是否需要通过 access_token?如果是,那么如何获得这个access_token?我被困在这里了.您的小帮助将不胜感激.谢谢.

Is it something with access_token that I need to pass? if yes then how to get this access_token? I'm so stuck here. Your little help will be appreciated. Thank you.

推荐答案

Vimeo 实现了 OAuth 2.0 Bearer Tokens.你应该像这样使用它:

Vimeo implements OAuth 2.0 Bearer Tokens. You should use it like this:

[serializer setValue:@"Bearer your_token_here" forHTTPHeaderField:@"Authorization"];

详细描述这里

这篇关于如何发出 API 请求以在 Objective-C 中获取私有 Vimeo 视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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