Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So through alot of trial and error I've got it working.</p> <p><strong>EDIT</strong> - Added Auth code</p> <pre><code>NSString *GOOGLE_CLIENT_AUTH_URL = @"https://www.google.com/accounts/ClientLogin?client=SomeName"; NSString *gSourceString = @"SomeName"; NSMutableURLRequest *httpReq = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:GOOGLE_CLIENT_AUTH_URL]]; [httpReq setTimeoutInterval:30.0]; [httpReq setCachePolicy:NSURLRequestReloadIgnoringCacheData]; [httpReq setHTTPMethod:@"POST"]; [httpReq addValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; NSString *requestBody = [[NSString alloc] initWithFormat:@"Email=%@&amp;Passwd=%@&amp;service=reader&amp;accountType=HOSTED_OR_GOOGLE&amp;source=%@", userString, passwordString, [NSString stringWithFormat:@"%@%d", gSourceString]]; [httpReq setHTTPBody:[requestBody dataUsingEncoding:NSASCIIStringEncoding]]; [requestBody release]; NSHTTPURLResponse *response = nil; NSData *data = nil; NSString *responseStr = nil; NSArray *responseLines = nil; int responseStatus = 0; data = [NSURLConnection sendSynchronousRequest:httpReq returningResponse:&amp;response error:&amp;error]; [httpReq release]; if ([data length] &gt; 0) { responseStr = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; responseStatus = [response statusCode]; if (responseStatus == 200 ) { authOK = TRUE; NSLog(@"Successfully authenticated with Google."); NSArray *authLines = nil; authLines = [responseStr componentsSeparatedByString:@"\n"]; int j; for (j =0; j &lt; [authLines count]; j++ ) { if ([[authLines objectAtIndex:j] rangeOfString:@"Auth="].length != 0) { NSMutableString *teststring = [NSMutableString stringWithString:[authLines objectAtIndex:j]]; [teststring replaceCharactersInRange:NSMakeRange(0,4) withString:@"auth"]; authString = teststring; } } } } NSString *auth = [[NSString alloc] initWithString: [NSString stringWithFormat:@"GoogleLogin %@", authString]]; NSDictionary *createHeader = [[NSDictionary dictionaryWithObjectsAndKeys:@"www.google.com", @"Host", @"EditApp", @"User-Agent", @"gzip, deflate", @"Accept-Encoding", auth, @"Authorization", nil]retain]; [auth release]; NSURL *url =[NSURL URLWithString:@"http://www.google.com/reader/api/0/token?client=EditApp"]; NSData *recieveData; NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc]initWithURL:url]; [urlRequest setHTTPMethod:@"GET"]; [urlRequest setAllHTTPHeaderFields:createHeader]; NSURLResponse *response; NSError *error; recieveData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&amp;response error:&amp;error]; // Get token NSString *pretokenString = [[NSString alloc] initWithData:recieveData encoding:NSASCIIStringEncoding]; tokenString = [pretokenString substringWithRange:NSMakeRange(2, [pretokenString length]-2)]; [pretokenString release]; [urlRequest release]; NSMutableURLRequest *thttpReq = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://www.google.com/reader/api/0/edit-tag?"]]; [thttpReq setTimeoutInterval:30.0]; [thttpReq setHTTPMethod:@"POST"]; NSString *authHeader = [NSString stringWithFormat:@"GoogleLogin %@", authString]; [thttpReq addValue:authHeader forHTTPHeaderField:@"Authorization"]; [thttpReq addValue:@"Content-Type" forHTTPHeaderField:@"application/x-www-form-urlencoded"]; // siteLink is the url of the feed // googlePostID is the id from the XML output: tag:google.com,2005:reader/item/e3345c69e174bdec NSString *trequestBody = [[NSString alloc] initWithFormat:@"a=user/-/state/com.google/read&amp;ac=edit-tags&amp;s=feed/%@&amp;i=%@&amp;T=%@", siteLink, googlePostID, tokenString]; [thttpReq setHTTPBody:[trequestBody dataUsingEncoding:NSASCIIStringEncoding]]; NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:thttpReq delegate:self startImmediately:NO]; [con scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; [con start]; </code></pre>
 

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