在 iPhone 谷歌阅读器应用程序中将项目标记为已读/未读
我正在使用 google reader API 中的数据并使用 GData 用于登录。
我希望能够将表格单元格内的帖子标记为已读/未读,但我发现事实上这一切主要都没有记录,很难找到解决方案,有什么想法/链接吗?
这是标记已读按钮的代码:
//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]);
}
来自此的日志是:
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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因此,通过大量的试验和错误,我已经让它发挥作用了。
编辑 - 添加了授权码
So through alot of trial and error I've got it working.
EDIT - Added Auth code
如果您熟悉 php,我最近写了一篇关于使用 google readi api 的教程。
http://mobile.tutsplus.com/tutorials/mobile-web-apps/building-a-mobile-web-application-with-the-google-reader-api/
我注意到的一件事是,在这个字符串
http://www.google.com/reader/api/0/edit-tag/a=user/-/state/com.google/read&async=true& ;s=feed/%@&i=%@
如果您不包含“编辑”标记,则网址应如下所示。你需要吗?编辑标签后。
http://www.google.com/reader/api/0/edit-tag?a=user/-/state/com.google/ read&async=true&s=feed/%@&i=%@&T=%@
用户登录后,您可以从此链接获取“编辑”令牌,https://www.google.com/reader/api/0/token
抱歉可以'对 Objective-C 的东西没有帮助。
If you are familiar with php I wrote a tutorial on using the google readi api recently.
http://mobile.tutsplus.com/tutorials/mobile-web-apps/building-a-mobile-web-application-with-the-google-reader-api/
One thing I notice is that in this string
http://www.google.com/reader/api/0/edit-tag/a=user/-/state/com.google/read&async=true&s=feed/%@&i=%@
Your not including the "edit" token the url should look like this. and you need the ? after edit-tag.
http://www.google.com/reader/api/0/edit-tag?a=user/-/state/com.google/read&async=true&s=feed/%@&i=%@&T=%@
You can get the "edit" token from this link once you have the user logged in, https://www.google.com/reader/api/0/token
Sorry can't help with objective-c stuff.