gpt4 book ai didi

ios - Twitter 帐户总是返回空白时间线?

转载 作者:行者123 更新时间:2023-11-29 03:19:24 26 4
gpt4 key购买 nike

我最近开始了一个 Xcode 项目,它需要我从 Twitter 帐户获取提要或时间线。我正在关注 this tutorial 。尽管当我编译代码时,它没有错误,但它不记录任何推文。我还下载了该项目的源代码,但仍然没有返回任何内容。我意识到这可能是我帐户的问题,但我最近发了一些推文,关注了一些人,转发了,基本上你可以做的一切来更新时间线!谢谢您的帮助!推特账号:@Pushahk

-(void)getTwitterFeed{
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.

self.TwitterPosts = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableLeaves error:&error];

dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Hi");
for (int i = 0; i < [self.TwitterPosts count]; i++) {
NSLog(@"%@", [self.TwitterPosts objectAtIndex:i]);
NSLog(@"Hi");
}

});


}];
}
}
else{
NSLog(@"%@", [error localizedDescription]);
}
}];

}

最佳答案

这是因为 include_entities 不再是 v1.1 API 中的有效参数(它在 v1 API 中)。您可能还需要提供屏幕名称,因为我认为在请求中设置 .account 属性仅用于 OAuth 目的。

来源:http://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline

关于ios - Twitter 帐户总是返回空白时间线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21296656/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com