TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | May 2017 |
Maintained by Trong Dinh.
It's a library on iOS which is suitable for OAuth1.
The idea based on FHSTwitterEngine (https://github.com/natesymer/FHSTwitterEngine) but has reduced more code and make it lightweight and suitable for all others OAuth1.
To run the example project, clone the repo, and run pod install
from the Example directory first.
Declare FHSTwitterEngine:
[[FHSTwitterEngine sharedEngine] setDelegate:self];
if([[FHSTwitterEngine sharedEngine] isAuthorized]) {
NSLog(@"YES");
[self callUserRequest];
} else {
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:@"https://api.twitter.com/oauth/access_token", kOAuth1_TOKEN,
@"https://api.twitter.com/oauth/request_token", kOAuth1_REQUEST_TOKEN,
@"https://api.twitter.com/oauth/authorize", kOAuth1_AUTHORIZE,
@"yRtOrW7lOURB0lTSaTWlN2fMv", kOAuth1_CONSUMER_KEY,
@"xOjRhL9mqzFf7Ie6Zv647K8FjPVeQyt2LcyPGAbkPYYae05VwP", kOAuth1_SECRET_KEY, nil];
NSError *err = [[FHSTwitterEngine sharedEngine] authWithInfo:dict];
if (!err) {
UIViewController *loginController = [[FHSTwitterEngine sharedEngine]loginControllerWithCompletionHandler:^(BOOL success) {
if(success) {
NSLog(@"YES");
[self callUserRequest];
} else {
NSLog(@"NO");
}
}];
[self presentViewController:loginController animated:YES completion:^{
}];
}
}
- (void)oauth1Reponsed:(NSDictionary *)dict {
NSLog(@"%@", dict);
}
- (void)callUserRequest {
id data = [[FHSTwitterEngine sharedEngine] sendGETRequestForURL:[NSURL URLWithString:@"https://api.twitter.com/1.1/account/verify_credentials.json"] andParams:nil];
NSLog(@"%@", data);
}
pod "OAuth1"
github "trongdth/OAuth1-for-iOS" "master"
Trong Dinh, [email protected]
OAuth1 is available under the APACHE license. See the LICENSE file for more info.