ios - How to auth in instagram with cookies? -


Then I have a code for auth instagram, but it does not work and the message " code> you have to switch cookies ". what I must to do? thanks for answer.

Now I try to get a token from instagram:

  NSURL * url = [NSURL URLWithString: @ "http://instagram.com"]; NSMutableURLRequest * Request = [[NSMutableURLRequest alloc] init]; [Request URL: url]; [Set http system: @ "gET"]; [Request Set HTTPSHowld Cookies: Yes]; NSDTA * URLDATA; NSHTTPURL response * feedback; NSError * Errors; urlData = [NSURLConnectionSynchronousRequest: Response Returning Request: And Response Error: & amp; Errors]; NSString * string = [[NSString alloc] initWithData: urlData encoding: NSUTF8StringEncoding]; NSRegularExpression * regex = [NSRegularExpression Regular expression: @ "csrf_token \": \ "(. *)," Option: 0 error: zero]; NSString * Token = String; NSTextCheckingResult * Match = [regex firstMatchInString: Token Options: 0 Category: NSMakeRange (0, [Token length])]; NSString * str = [[token substringWithRange: [match rangeAtIndex: 1]] stringByReplacingOccurrencesOfString: @ "\"} "withString: @" "]; NSLog (@"% @ ", str); NSString * post = [NSString stringWithFormat: @ "csrfmiddlewaretoken =% @ & amp; Username =% @ & amp; Password =% @ ", str, @" NNN ", @" nnnpass "]; NSData * POSTDATA = [Post dataUsingEncoding: NSUTF8StringEncoding allowLossyConversion: YES]; NSString * postLength = [NSString stringWithFormat: @"% d ", [postData length ]]; request = [[NSMutableURLRequest alloc] init]; [requestURL: [NSURL URLWithString: @ "https://instagram.com/accounts/login/"]], [request setHTTPMethod: @ "Post"] [request setHTTPShouldHandleCookies: Yes] [request setValue: postLength forHTTPHeaderField: @ "content-length"] [request setValue: @ "application / x-www FORM urlencoded" forHTTPHeaderField: @ "content type"] [request setHTTPBody: POSTDATA] ; urlData = [NSURLConnection sendSynchronousRequest: RequestingResponse: & amp; Response Error: & Errors]; NSString * string2 = [[NSString alloc] initWithData: U Areldiatti Encoding: Ansutif 8 string encoding]; Anselog (@ "% @", the string 2);    

  NSDictionary * cookieProperties = [NSDictionary dictionary Sathobjektawrke: @ "" Ansactiteepikyukeedomen, @ "\\", Ansactiteepikyukeepath, @ "Sisarftokn" Ansactiteepikyukinam, @ "2DFDBAAEA 7752882D792E49D79C 0048", NSHTpcQQQ value, zero]; NSHTT Cookie * Cookie = [NSHTP Cookie Cookies with Properties: CookieProperties]; NSArray * cookieArray = [NSArray arrayWithObjects: cookie, zero]; NSDictionary * Header = [NSHTQ Cookie RequestHeaderFields Wit Cookies: CookiesArere];   

Add to the POST request: [Request AllHTTPHeaderFields: headers];

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -