【问题标题】:Twitter Follow API推特关注 API
【发布时间】:2014-01-07 06:32:46
【问题描述】:

我需要让这个人使用 API 在 twitter 上关注另一个人。

我知道 twitter 迁移到 v1.1

我用这些API来获取两个人的关系,

https://api.twitter.com/1.1/friendships/exists.json?screen_name_a=Person1&screen_name_b=Person2

https://api.twitter.com/1.1/friendships/lookup.json?screen_name=Person1,Person2

但我得到的最终结果是,

{
errors =     (
            {
        code = 215;
        message = "Bad Authentication data";
    }
);
}

是否有任何其他确切的 API 可以找到我的解决方案。

任何人帮助我找到一个人正在关注另一个人。

【问题讨论】:

  • 错误是“错误的身份验证数据” - 您是否正确注册了您的应用并获得了身份验证令牌?
  • Terence Eden 感谢您的回复。我用这个方法stackoverflow.com/questions/8085055/…,效果很好。

标签: twitter


【解决方案1】:

试试这个代码,你可以得到你所期望的,

-(void) followUsOnTwitter {

ACAccountStore *accountStore = [[ACAccountStore alloc] init];

ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(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:@"abcd" forKey:@"screen_name"];    // Change the Value String
            [tempDict setValue:@"true" forKey:@"follow"];

            TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://api.twitter.com/1.1/friendships/create.json"]
                                                         parameters:tempDict
                                                      requestMethod:TWRequestMethodPOST];

            [postRequest setAccount:twitterAccount];

            [postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                NSString *output = [NSString stringWithFormat:@"HTTP response status: %i", [urlResponse statusCode]];
                NSLog(@"%@", output);
                if (urlResponse.statusCode == 200)
                {

                    // follow by usr

                }
            }];
        }
    }
}];
}

【讨论】:

    【解决方案2】:

    您可以查看此答案: 在 v1.1 API 中,他们已将其替换为friendships/lookup API,您可以在其中指定最多 100 个用户的逗号分隔列表,它会告诉您身份验证用户与指定的每个用户之间的连接

    【讨论】:

    • Anil Dhiman,我也对此进行了检查,请在第二个链接中查看我的问题,..
    猜你喜欢
    • 2016-04-07
    • 2011-01-04
    • 1970-01-01
    • 2011-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-22
    相关资源
    最近更新 更多