gpt4 book ai didi

ios - SLRequest - Twitter 返回代码 215(错误的身份验证数据)

转载 作者:可可西里 更新时间:2023-11-01 06:10:03 26 4
gpt4 key购买 nike

我有上传照片的应用程序,就像在 Instagram 应用程序中一样。首先我的应用上传照片并返回链接。然后在状态消息中发送链接。当我在我的 iPhone 上测试时,一切正常,但当我在另一部 iPhone 上测试时,twitter 返回代码 215 错误的身份验证数据。任何想法可能是错的?感谢回复。

- (void)tweet:(NSString *)identifier withCompletionHandler:(void (^)())completionHandler {
ACAccountStore *accountStore = [[ACAccountStore alloc] init];

// Create an account type that ensures Twitter accounts are retrieved.
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

// Request access from the user to use their Twitter accounts.
[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
if(granted) {
if (identifier) {
// Get the list of Twitter accounts.
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];

if ([accountsArray count] > 0) {
// Grab the initial Twitter account to tweet from.
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/statuses/update.json"];
NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Check out this great flick on BLA BLA %@", [BLA_URL stringByAppendingFormat:@"/%@/%@", @"flick", identifier]]
forKey:@"status"];

SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodPOST
URL:url
parameters:dict];
[request setAccount:[accountsArray lastObject]];
[request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if ([urlResponse statusCode] == 200) {
NSLog(@"TWEEET!");

}
else {
NSError *jsonError;
id data = [NSJSONSerialization JSONObjectWithData:responseData
options:NSJSONReadingMutableLeaves
error:&jsonError];

dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Twitter response"
message:[NSString stringWithFormat:@"%d S: %d %@", [error code], [urlResponse statusCode], data]
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
NSLog(@"NOOO TWEEET!");
[alertView show];
completionHandler();
});
}
}];
...

和预检功能:

- (IBAction)twitterButtonTapped:(id)sender {
if ([self.twitterButton isSelected]) {
[self.twitterButton setSelected:NO];
}
else {
[self.twitterButton setSelected:YES];

ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

[accountStore requestAccessToAccountsWithType:accountType withCompletionHandler:^(BOOL granted, NSError *error) {
if (!granted) {
[self.twitterButton setSelected:NO];

UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Twitter access"
message:@"Please make sure you have allowed twitter for BLA BLA in your Settings."
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO];
}
}];
}

最佳答案

好的,我有答案了!问题是其他 iPhone 的帐户数据不完整 - 这意味着您必须在“设置”应用中填写用户名和密码。

关于ios - SLRequest - Twitter 返回代码 215(错误的身份验证数据),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19081530/

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