从iPhone向Twitter提交推文时出现问题

| MGTwitterEngine.m
- (NSString *)username
{
return [[_username retain] autorelease];
}


- (NSString *)password
{
return [[_password retain] autorelease];
}


- (void)setUsername:(NSString *)newUsername password:(NSString *)newPassword
{


// Set new credentials.


   [_username release];

_username = [newUsername retain];

    [_password release];


_password = [newPassword retain];


if ([self clearsCookies]) {

    // Remove all cookies for twitter, to ensure next connection uses new credentials.

    NSString *urlString = [NSString stringWithFormat:@\"%@://%@\", 
                           (_secureConnection) ? @\"https\" : @\"http\", 
                           _APIDomain];

    NSURL *url = [NSURL URLWithString:urlString];

    NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    NSEnumerator *enumerator = [[cookieStorage cookiesForURL:url] objectEnumerator];
    NSHTTPCookie *cookie = nil;
    while (cookie == [enumerator nextObject]) {
        [cookieStorage deleteCookie:cookie];
    }
}
}

- (NSString *)sendUpdate:(NSString *)status
{
return [self sendUpdate:status inReplyTo:0];
}


- (NSString *)sendUpdate:(NSString *)status inReplyTo:(unsigned long)updateID
{
if (!status) {
    return nil;
}

NSString *path = [NSString stringWithFormat:@\"statuses/update.%@\", API_FORMAT];


NSString *trimmedText = status;

if ([trimmedText length] > MAX_MESSAGE_LENGTH) {


    trimmedText = [trimmedText substringToIndex:MAX_MESSAGE_LENGTH];

}

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];

[params setObject:trimmedText forKey:@\"status\"];

if (updateID > 0) {

    [params setObject:[NSString stringWithFormat:@\"%u\", updateID] forKey:@\"in_reply_to_status_id\"];

}

NSString *body = [self _queryStringWithBase:nil parameters:params prefixed:NO];


return [self _sendRequestWithMethod:HTTP_POST_METHOD path:path 
                    queryParameters:params body:body 
                        requestType:MGTwitterUpdateSendRequest
                       responseType:MGTwitterStatus];


}
TwitterPostViewController.m
- (IBAction)submitTweet{

[tweet resignFirstResponder];

if([[tweet text] length] > 0){


    NSLog(@\"%@\",[[NSUserDefaults standardUserDefaults] valueForKey:@\"TwitterUsername\"]);

    NSLog(@\"%@\",[[NSUserDefaults standardUserDefaults] valueForKey:@\"TwitterPassword\"]);       


    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

    [engine sendUpdate:[tweet text]];

}

}



- (void)requestFailed:(NSString *)requestIdentifier withError:(NSError *)error{

NSLog(@\"Fail: %@\", error);

[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

UIAlertView *failAlert;

if([error code] == 401){

    failAlert = [[UIAlertView alloc] initWithTitle:@\"Error\" message:@\"Incorrect Username & Password.\" delegate:nil cancelButtonTitle:@\"OK\" otherButtonTitles:nil];

    [failAlert setTag:10];

    [failAlert setDelegate:self];

} 
else 
{

    failAlert = [[UIAlertView alloc] initWithTitle:@\"Error\" message:@\"Failed sending status to Twitter.\" delegate:nil cancelButtonTitle:@\"OK\" otherButtonTitles:nil];

}

[failAlert show];

[failAlert release];

}
它显示了错误的用户名和密码的失败弹出窗口 我已经通过nslog检查了用户名和密码是否正确。 有什么问题吗?     
已邀请:
        您正在使用的MGTwitterEngine版本似乎正在尝试使用基本身份验证。在Twitter中已关闭该页面,以支持OAuth。获取较新版本的MGTwitterEngine(或支持OAuth的fork)。     

要回复问题请先登录注册