首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在ios7中获取私人推文?

如何在ios7中获取私人推文?
EN

Stack Overflow用户
提问于 2013-10-11 13:48:51
回答 1查看 291关注 0票数 0

我知道推特整合和私人推特有很多东西。但是我想知道,如果我在TWRequest中使用ios7,那么它是否有效?

代码语言:javascript
复制
My code snippet as follows.
ACAccountStore *accountStore = [[ACAccountStore alloc] init];

    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error){
        if(granted)
        {
            // Get the list of Twitter accounts.
            NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];

            // For the sake of brevity, we'll assume there is only one Twitter account present.
            // You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
            if ([accountsArray count] > 0) {
                // Grab the initial Twitter account to tweet from.
                ACAccount *twitterAccount = [accountsArray objectAtIndex:0];

                NSMutableDictionary *tempDict = [[NSMutableDictionary alloc] init];
                [tempDict setValue:@"rohit40793982" forKey:@"screen_name"];
                //[tempDict setValue:@"true" forKey:@"follow"];
                // [tempDict setValue:@"683286" forKey:@"user_id "];

                TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://twitter.com/snehalikanksha/status/388535072359317504.json"]
                                                             parameters:tempDict
                                                          requestMethod:TWRequestMethodPOST];


                [postRequest setAccount:twitterAccount];

                [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
                {
                    NSLog(@"%@",urlResponse);
                    NSArray  *tweets = [NSJSONSerialization JSONObjectWithData:responseData
                                                                       options:kNilOptions
                                                                         error:&error];
                    NSLog(@"%@",tweets);
                    NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
                    NSLog(@"%@", output);
                    [self performSelectorOnMainThread:@selector(displayText) withObject:output waitUntilDone:NO];

                }];
            }
        }
    }];

有人能帮我吗?给出了Http的误差403号。和日志显示

代码语言:javascript
复制
"Your account may not be allowed to perform this action. Please <a class=\"js-reload\" href=\"#\">refresh the page</a> and try again."
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-10-26 17:26:50

我不知道您想要做什么,但是您的代码不能工作的原因是您没有使用Twitter端点。

如果您想获取特定推特的详细信息,可以使用获取状态/显示/:id

您必须更改代码,以便:

代码语言:javascript
复制
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/show.json?id=388535072359317504"];

TWRequest *request = [[TWRequest alloc] initWithURL:url
                                         parameters:nil
                                      requestMethod:TWRequestMethodGET];

通过将每个端点映射到Objective方法,STTwitter库可以帮助您使用API。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19319836

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档