Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to authenticate on twitter from iphone using asihttp?
    primarykey
    data
    text
    <p>I used the asihttp library to connect to twitter.</p> <p>The idea is to send a login request, get the response and extract the session ID/auth code from the response's cookie header. Then you can use that session ID/auth code for consecutive calls.</p> <p>I don't obtain the auth_code because the authentication fails. how can I fix this?</p> <p>the code is below:</p> <pre class="lang-c prettyprint-override"><code> - (void) login { NSString *username = @"user"; NSString *password = @"pass"; NSURL *url = [NSURL URLWithString:@"https://twitter.com/sessions?phx=1"]; ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease]; [request addRequestHeader:@"User-Agent" value: @"ASIHTTPRequest"]; [request setPostValue:username forKey:@"session[username_or_email]"]; [request setPostValue:password forKey:@"session[password]"]; [request setDelegate: self]; [request setDidFailSelector: @selector(loginRequestFailed:)]; [request setDidFinishSelector: @selector(loginRequestFinished:)]; [request startAsynchronous]; } - (void)loginRequestFailed:(ASIHTTPRequest *)request { NSError *error = [request error]; NSLog(@"login request failed with error: %@", [error localizedDescription]); } - (void)loginRequestFinished:(ASIHTTPRequest *)request { NSString *responseString = [[request responseHeaders] objectForKey:@"Set-Cookie"]; NSLog(@"%@",responseString); } </code></pre> <p>I tried to connect from shell and it works.</p> <pre><code>curl -d 'session[user_or_emai]=user&amp;session[password]=pass' https://twitter.com/sessions </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload