gpt4 book ai didi

iphone - 尝试使用新的 iOS 5 API 向 Twitter 上的某人发送 "follow",得到 406 返回错误。为什么?

转载 作者:太空狗 更新时间:2023-10-30 03:10:08 24 4
gpt4 key购买 nike

尝试使用新的 iOS 5 API 在 Twitter 上“关注”某人,收到 406 返回错误。为什么?

我的代码正确吗?需要找出为什么这不起作用....

    - (void)followOnTwitter:(id)sender
{
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:@"sortitapps" forKey:@"screen_name"];
[tempDict setValue:@"true" forKey:@"follow"];

TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"http://api.twitter.com/1/friendships/create.format"]
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);

}];
}
}
}];
}

所有代码看起来都是正确的。参数不正确?网址是否正确?在这里需要一些指导....

最佳答案

找到了我自己问题的答案...我将 URL 更改为 https://api.twitter.com/1/friendships/create.json它奏效了。

不要忘记它是 https,而不仅仅是 http。

关于iphone - 尝试使用新的 iOS 5 API 向 Twitter 上的某人发送 "follow",得到 406 返回错误。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8085785/

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