Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 763261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:31:55+00:00 2026-05-14T16:31:55+00:00

I am trying to make Twitter work in my app and everything works fine

  • 0

I am trying to make Twitter work in my app and everything works fine except the code does not seem to recognize an error from Twitter. If the username/password are not valid, I get an error message through this function:

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
{
 NSString* strData = [[[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:NSASCIIStringEncoding] autorelease];
 NSLog(@"Received data: %@", strData ) ;
 return ;
}

It prints: Received data:

Could not authenticate you.
.

However, the app continues to the post a tweet view I have and ignores the error. Obviously, I do not have something setup right to detect such an error from twitter so my question is how do I get Xcode to recognize an error like this? This uses basic http auth btw and don’t mention anything about OAuth…just trying to get this to work for now.

    -(void) onLogin:(id)sender
    { 
 [loading1 startAnimating];

 NSString *postURL = @"http://twitter.com/account/verify_credentials.xml";
 NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString:postURL ] ];

 NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];

 if (!theConnection) 
 {
  UIAlertView* aler = [[UIAlertView alloc] initWithTitle:@"Network Error" message:@"Failed to Connect to twitter" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
  [aler show];
  [aler release];
 } 

 else
 {
  receivedData = [[NSMutableData data] retain];
 }

 [request release];
    }

    -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
    {
    if ([challenge previousFailureCount] == 0 && ![challenge proposedCredential]) 
 {
        NSURLCredential *newCredential;
        newCredential=[NSURLCredential credentialWithUser:txtUsername.text
                                                 password:txtPassword.text
                                              persistence:NSURLCredentialPersistenceNone];

        [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
        } 
 else 
 {
  isAuthFailed = YES;
        [[challenge sender] cancelAuthenticationChallenge:challenge];
        }
    } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:31:56+00:00Added an answer on May 14, 2026 at 4:31 pm

    ok so I can now get an error response or a authentication response in xml. now, how do I say, use this response as a triggering factor for connectionDidFailWithError because if twitter send me back an error, I want to give an in-app error.

    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [receivedData appendData:data];
    
    NSXMLParser* parser = [[NSXMLParser alloc] initWithData:data];
    [parser setDelegate:self];
    [parser parse];
    
    return;
    }
    
    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSMutableString *)string
    {
    NSLog(@"response: %@", string);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update status on twitter using twitter4j. Everything works fine on
I am trying to make our App work on iOS6, but there is a
I'm trying to make an thumbnail gallery (2x2) with twitter bootstrap, but I'm not
I'm trying to make Twitter's Bootstrap API (http://bootstrap.opalang.org/) work in Opa by trying some
I am trying to make work twitter oAuth with twitterizer, but I am unable.
i'm trying make simple app twitter and i use twitter4j library and i got
I am trying to make an app that parses data from Twitter using JSON
I'm trying to make a twitter like system that scrolls through info slowly and
I am trying to make a simple twitter client in C. I'm new at
I'm trying to make an AJAX form that will update a twitter status when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.