Permalink
Browse files

use HatenaBookmark jsonlite API.

  • Loading branch information...
1 parent 59d5eb4 commit 6d9855563a00a76a96fd115f417f5d05b872023d laiso committed Aug 26, 2009
Showing with 27 additions and 4 deletions.
  1. +3 −4 Classes/WebViewController.m
  2. +24 −0 patch/hatena-touch-jsonliteapi.path
@@ -41,16 +41,15 @@ - (void)dealloc {
- (void)_loadPageInfo {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSURL *webServiceURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://b.hatena.ne.jp/entry/json/%@", pageURL]];
+ NSURL *webServiceURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://b.hatena.ne.jp/entry/jsonlite/%@", pageURL]];
NSURLRequest *req = [NSURLRequest requestWithURL:webServiceURL cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
NSData *data;
NSHTTPURLResponse *res;
NSError *error;
data = [NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&error];
-
- NSString *temp = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
- NSString *json = [[temp substringFromIndex:1] substringToIndex:[temp length] -2];
+
+ NSString *json = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
pageInfo = [[json JSONValue] retain];
[[[self navigationItem] rightBarButtonItem] setEnabled:YES];
@@ -0,0 +1,24 @@
+diff --git a/Classes/WebViewController.m b/Classes/WebViewController.m
+index b7228e2..e54e029 100644
+--- a/Classes/WebViewController.m
++++ b/Classes/WebViewController.m
+@@ -42,16 +42,15 @@ static NSObject *webViewcreateWebViewWithRequestIMP(id self, SEL _cmd, NSObject*
+ - (void)_loadPageInfo {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+- NSURL *webServiceURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://b.hatena.ne.jp/entry/json/%@", pageURL]];
++ NSURL *webServiceURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://b.hatena.ne.jp/entry/jsonlite/%@", pageURL]];
+ NSURLRequest *req = [NSURLRequest requestWithURL:webServiceURL cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
+
+ NSData *data;
+ NSHTTPURLResponse *res;
+ NSError *error;
+ data = [NSURLConnection sendSynchronousRequest:req returningResponse:&res error:&error];
+-
+- NSString *temp = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
+- NSString *json = [[temp substringFromIndex:1] substringToIndex:[temp length] -2];
++
++ NSString *json = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
+ pageInfo = [[json JSONValue] retain];
+
+ [[[self navigationItem] rightBarButtonItem] setEnabled:YES];

0 comments on commit 6d98555

Please sign in to comment.