我正在尝试使用iOS SDK中的Twitter API获取用户的Twitter时间轴,并显示一条错误消息:
code = 92; message = "SSL is required";
我在错误中进行了搜索,并在Twitter API网站上找到了此页面,但是我不知道如何在iOS中使用它。
这是我的代码:
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[account requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error)
{
if (granted == YES){
NSArray *arrayOfAccounts = [account accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0) {
ACAccount *twitterAccount = [arrayOfAccounts lastObject];
NSURL *requestAPI = [NSURL URLWithString:@"http://api.twitter.com/1.1/statuses/user_timeline.json"];
NSMutableDictionary *parameters = [[NSMutableDictionary alloc] init];
[parameters setObject:@"100" forKey:@"count"];
[parameters setObject:@"1" forKey:@"include_entities"];
SLRequest *posts = [SLRequest requestForServiceType:SLServiceTypeTwitter requestMethod:SLRequestMethodGET URL:requestAPI parameters:parameters];
posts.account = twitterAccount;
[posts performRequestWithHandler:
^(NSData *response, NSHTTPURLResponse
*urlResponse, NSError *error)
{
// The NSJSONSerialization class is then used to parse the data returned and assign it to our array.
array = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];
if (array.count != 0) {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"%@",array);
});
}
}];
}
} else {
// Handle failure to get account access
NSLog(@"%@", [error localizedDescription]);
}
}];
有办法解决这个问题吗?
在网址中使用“ https”:
https://api.twitter.com/1.1/statuses/user_timeline.json
文件:https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句