RWMViemoClient
是一个用于与 Vimeo 高级 API 交互的 AFHTTPRequestOperationManager
子类。
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>custom_scheme</string>
</array>
</dict>
</array>
[[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);
}
}];
}
- (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];
}
}];
}
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 文件。