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

  • SEARCH
  • Home
  • 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 4016428
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:44:20+00:00 2026-05-20T09:44:20+00:00

I am developing an app using data from google reader’s API and using GData

  • 0

I am developing an app using data from google reader’s API and using GData for login.

I want to be able to mark a post inside a table cell as read / unread, but am finding the fact that this is all mainly undocumented hard to work out a solution, any ideas / links?

Here is the code for the mark read button:

//Get the token

NSString *tokenString = [NSString stringWithFormat:@"https://www.google.com/reader/api/0/token"];

NSURL *tokenURL = [NSURL URLWithString:tokenString];
NSMutableURLRequest *tokenRequest = [NSMutableURLRequest requestWithURL:tokenURL];

NSString *tokenStringResult;
NSArray *listItems;

NSError *tokenError = nil;
NSURLResponse *tokenResponse = nil;
NSData *tokenData = [NSURLConnection sendSynchronousRequest:tokenRequest
                                          returningResponse:&tokenResponse
                                                      error:&tokenError];
if (tokenData) 
{
    tokenStringResult = [[NSString alloc] initWithData:tokenData encoding:NSUTF8StringEncoding];

    listItems = [tokenStringResult componentsSeparatedByString:@"/"];
} 
else 
{
    NSLog(@"tokenError = %@", tokenError);
}

// Mark it as read

NSString *readerURLString = [NSString stringWithFormat:@"http://www.google.com/reader/api/0/edit-tag?a=user/-/state/com.google/read&async=true&s=feed/%@&i=%@&T=%@", siteLink, postID, [listItems lastObject]];

NSURL *readerURL = [NSURL URLWithString:readerURLString];

NSMutableURLRequest *readerRequest = [NSMutableURLRequest requestWithURL:readerURL];

[mAuth authorizeRequest:readerRequest];

NSError *error = nil;
NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:readerRequest
                                     returningResponse:&response
                                                 error:&error];
if (data) 
{
    NSHTTPURLResponse * httpResponse = (NSHTTPURLResponse *) response;
    assert( [httpResponse isKindOfClass:[NSHTTPURLResponse class]] );

    NSLog(@"response.allHeaderFields = %@", [httpResponse allHeaderFields]);

    NSLog(@"response.statusCode = %i", [httpResponse statusCode]);

} 

the log from this is:

response.statusCode = {
"Cache-Control" = "private, max-age=0";
"Content-Length" = 1334;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Fri, 21 Jan 2011 03:49:07 GMT";
Expires = "Fri, 21 Jan 2011 03:49:07 GMT";
Server = GSE;
"X-Content-Type-Options" = nosniff;
"X-Frame-Options" = SAMEORIGIN;
"X-Reader-Google-Version" = "527-000";
"X-Reader-User" = 01940378872835844713;
"X-Xss-Protection" = "1; mode=block";
}
response.statusCode = 400
  • 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-20T09:44:20+00:00Added an answer on May 20, 2026 at 9:44 am

    So through alot of trial and error I’ve got it working.

    EDIT – Added Auth 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=%@&Passwd=%@&service=reader&accountType=HOSTED_OR_GOOGLE&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:&response error:&error];
    
    [httpReq release];
    
    if ([data length] > 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 < [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:&response error:&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&ac=edit-tags&s=feed/%@&i=%@&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];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the data mapper pattern in a PHP app I'm developing and have
I'm developing an ASP.NET 2.0 app using Visual Studio 2008. If I want to
i am developing one app i am using upload image in sdcard getting from
We're currently developing a J2EE web app using JPA as our data access layer.
I am developing an iOS app using iOS 4.2 SDK, but I want the
I am developing a forms app (not web) for Windows Mobile, using .NET CF
I'm using the RESTful authentication Rails plugin for an app I'm developing. I'm having
I'm using Windows Vista x64 with SP1, and I'm developing an ASP.NET app with
I'm developing a website. I'm using a single-page web-app style, so all of the
we're developing a web app to cover all aspects of a printing company from

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.