RWMVimeoClient 1.0.0

RWMVimeoClient 1.0.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2014年12月

未知拥有者维护。



  • Michał Zaborowski

RWMViemoClient

RWMViemoClient 是一个用于与 Vimeo 高级 API 交互的 AFHTTPRequestOperationManager 子类。

示例用法

在 Info.plist 中注册自定义重定向 URL Scheme

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>custom_scheme</string>
        </array>
    </dict>
</array>

OAuth Vimeo 认证

[[RWMVimeoOperationManager sharedOperationManager] setClientId:@"YOUR_CLIENT_ID"
                                         secret:@"YOUR_SECRET"
                                    redirectURL:[NSURL URLWithString:@"custom_scheme://login"]];

// Check if authentication token was storen in user default
OAToken *token = [[OAToken alloc] initWithUserDefaultsUsingServiceProviderName:@"VimeoClient" prefix:@"RWM"];

if (token) {
    // Set authenticator token for API Calls
    [RWMVimeoOperationManager sharedOperationManager].authenticationToken = token;
    [self searchQuery];
} else {
    // Authenticate user
    [[RWMVimeoOperationManager sharedOperationManager] authenticateWithBlock:^(NSError *error) {
        if (error) {
            NSLog(@"%@",error);
        }
    }];
}

处理 OpenURL

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    return [[RWMVimeoOperationManager sharedOperationManager] handleOpenURL:url fallbackHandler:^(OAToken *token, NSError *error) {
        if (error) {
            NSLog(@"%@",error);
        } else {
            [token storeInUserDefaultsWithServiceProviderName:@"VimeoClient" prefix:@"RWM"];
            [self searchQuery];
        }
    }];
}

API 使用

NSDictionary *paramters = @{
                            @"page" : @2,
                            @"per_page" : @5,
                            @"query" : @"test",
                            @"full_response" : @1
                            };

[[RWMVimeoOperationManager sharedOperationManager] vimeoRequestOperationWithHTTPMethod:@"GET" APIMethod:@"vimeo.videos.search" parameters:paramters success:^(AFHTTPRequestOperation *operation, id responseObject) {

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

}];

联系方式

Michał Zaborowski

许可证

RWMViemoClient 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。