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

问题描述

限时删除!!

我正在开发iOS应用程序以播放私人Vimeo视频。私人视频被授予隐私从Vimeo网站隐藏的视频和给定域名,以便这些视频只会在我的网站上购买和播放。我使用Vimeo PRO帐户。



我使用VIMNetworking SDK并通过使用客户端详细信息在didFinishLaunchingWithOptions()中进行身份验证。

现在我必须提出API请求以获得直接的视频网址。我不知道如何做到这一点。 Vimeo不提供Objective-C的文档。通过使用下面的代码,我可以获得公共视频回复,但不能用于私人视频。

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

我甚至试过这段代码以获得私人视频。但是我得到了回应。

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

client.requestSerializer = [AFJSONRequestSerializer serializer];

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


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

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

}];

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

  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/videosparameters:param success:^(AFHTTPRequestOperation * operation,id responseObject)
{

NSLog(@忘记密码JSON:%@,responseObject);


$ b失败:^(AFHTTPRequestOperation * operation,NSError * error){
NSLog(@Error:%@,error.description);

}];

是否需要传递access_token?如果是的话,那么如何获得这个access_token?我在这里卡住了。你的小帮助将不胜感激。谢谢。

解决方案

Vimeo实现了OAuth 2.0承载令牌。你应该像这样使用它:

  [serializer setValue:@Bearer your_token_hereforHTTPHeaderField:@Authorization]; 

详细介绍


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.

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

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);

    }];

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);

      }];

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 implements OAuth 2.0 Bearer Tokens. You should use it like this:

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

It is described in details here

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

1403页,肝出来的..

09-06 18:05