在iOS中使用SSL连接到Twitter API

空军基地

我正在尝试使用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]);

     }

 }];

有办法解决这个问题吗?

伊桑·米克(Ethan Mick)

在网址中使用“ 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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法从“无家可归”框连接到Twitter API

来自分类Dev

使用chrome.bluetoothLowEnergy API连接到iOS设备

来自分类Dev

使用chrome.bluetoothLowEnergy API连接到iOS设备

来自分类Dev

使用Python连接到JIRA API时SSL3证书验证失败

来自分类Dev

使用Python连接到JIRA API时SSL3证书验证失败

来自分类Dev

在Meteor中使用SockJS连接到外部服务或流API

来自分类Dev

连接到Google Analytics API时Java中的SSL例外

来自分类Dev

使用Angular连接到外部API

来自分类Dev

无法使用Java API连接到Hbase

来自分类Dev

使用Facebook帐户连接到SoundCloud API

来自分类Dev

使用Soap Java连接到Magento API

来自分类Dev

使用Plain JAVA API连接到JIRA

来自分类Dev

无法使用或连接到Mailmans REST API

来自分类Dev

使用R连接到Pocket API

来自分类Dev

使用Java API连接到本地TFS

来自分类Dev

使用 ColdFusion cfhttp 连接到远程 API

来自分类Dev

无法使用 JavaMail API 连接到 Protonmail

来自分类Dev

通过Alamofire在SWIFT中使用Twitter API

来自分类Dev

在Python中使用Twitter搜索API

来自分类Dev

通过Alamofire在SWIFT中使用Twitter API

来自分类Dev

Amazon 使用 Amplify AWS IOS 将多个表连接到一个 API

来自分类Dev

无法连接到API

来自分类Dev

使用API密钥和机密连接到交易API(Poloniex)

来自分类Dev

在iOS中使用Yelp API

来自分类Dev

Xamarin iOS模拟器无法连接到Rest API

来自分类Dev

如何将包装DLL连接到API DLL以便在C#项目中使用?

来自分类Dev

使用 URLSession 在 ios 中使用 POST API

来自分类Dev

Wampserver无法连接到API

来自分类Dev

从Java连接到PHP API