Re: [twitter-dev] Problem with JSON
It looks like you are implicitly assuming that the OS will send you chunks of stream data that correspond to single, complete parsable chunks. That may have worked accidentally because that happened to be how they arrived in time, but it is definitely unreliable (as you found). What you should do in connection:didReceiveData: is buffer the data you received, and split it up yourself by looking for the delimiters that separate individual tweets, and then parse those individual tweets. -josh On Sun, Apr 18, 2010 at 5:29 AM, Carl Knott wrote: > I have developed an iPhone app that connects to the streaming API the > app was running correctly for 2 months but since yesterday it has not! I can > still receive a response from the stream but now I can not parse the JSON > correctly... My parser believes that the stream is incorrectly structured. I > get a few correctly structured results and then I get errors. Is it a > problem at twitters end or mine? Below is a snippet of my code. > To initialize the HTTP request: > request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString > stringWithFormat: > @"http://%@:%@@stream.twitter.com/1/statuses/filter.json?track=%@";, > [[NSUserDefaults standardUserDefaults] stringForKey:@"UsernameKey"], > [[NSUserDefaults standardUserDefaults] stringForKey:@"PasswordKey"], > searchFormat]] ]; > > - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData > *)data { > NSString *responseString = [[[NSString alloc] initWithData:data > encoding:NSUTF8StringEncoding] autorelease]; > NSDictionary *dictionary = (NSDictionary *) [parser > objectWithString:responseString error:nil]; > NSDictionary *user = (NSDictionary *) [dictionary valueForKey:@"user"]; > if([user valueForKey:@"screen_name"] != nil) { > Tweet *tweet = [[Tweet alloc] init]; > [tweet setScreenName:[user valueForKey:@"screen_name"]]; > [tweet setLink:[user valueForKey:@"profile_image_url"]]; > [tweet setMessage:[dictionary valueForKey:@"text"]]; > //do something > [tweet release]; > } > } > -- Subscription settings: http://groups.google.com/group/twitter-development-talk/subscribe?hl=en
Re: [twitter-dev] Problem with JSON
If you can store the offending JSON and then run it through a JSON verifier to see if it's malformed, that'd be great. Please post the offending JSON and the error. Otherwise, if there is a case where disambiguation is impossible, please give examples of the two messages types that cannot be categorized. Chances are that there is a new field in the message that your logic isn't handling correctly. I'm not aware of any payload of rendering changes recently. -John Kalucki http://twitter.com/jkalucki Infrastructure, Twitter Inc. On Sun, Apr 18, 2010 at 2:29 AM, Carl Knott wrote: > I have developed an iPhone app that connects to the streaming API the > app was running correctly for 2 months but since yesterday it has not! I can > still receive a response from the stream but now I can not parse the JSON > correctly... My parser believes that the stream is incorrectly structured. I > get a few correctly structured results and then I get errors. Is it a > problem at twitters end or mine? Below is a snippet of my code. > > To initialize the HTTP request: > > request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString > stringWithFormat: @"http://%@:%@@ > stream.twitter.com/1/statuses/filter.json?track=%@", [[NSUserDefaults > standardUserDefaults] stringForKey:@"UsernameKey"], [[NSUserDefaults > standardUserDefaults] stringForKey:@"PasswordKey"], searchFormat]] ]; > > > - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData > *)data { > NSString *responseString = [[[NSString alloc] initWithData:data > encoding:NSUTF8StringEncoding] autorelease]; > NSDictionary *dictionary = (NSDictionary *) [parser > objectWithString:responseString error:nil]; > NSDictionary *user = (NSDictionary *) [dictionary valueForKey:@"user"]; > if([user valueForKey:@"screen_name"] != nil) { > Tweet *tweet = [[Tweet alloc] init]; > [tweet setScreenName:[user valueForKey:@"screen_name"]]; > [tweet setLink:[user valueForKey:@"profile_image_url"]]; > [tweet setMessage:[dictionary valueForKey:@"text"]]; > //do something > [tweet release]; > } > } > > -- Subscription settings: http://groups.google.com/group/twitter-development-talk/subscribe?hl=en
Re: [twitter-dev] problem with json api - empty results list
That is because there are no results to return: http://search.twitter.com/search?q=from%3AMMFlint Abraham On Thu, Nov 26, 2009 at 07:13, marcin wrote: > Hello group, I have a problem with one single url: > http://search.twitter.com/search.json?q=from%3AMMFlint > I integrated that json flow in my app but since about one week the > "results" array stays empty. I was trying to find info about limits, > valid dates, etc but there is nothing about that on the json api page. > Can somebody help me with that issue ? What am I doing wrong ? > > > Thanks in advance > > > marcin > -- Abraham Williams | Community Evangelist | http://web608.org Hacker | http://abrah.am | http://twitter.com/abraham Project | Awesome Lists | http://twitterli.st This email is: [ ] blogable [x] ask first [ ] private. Sent from Madison, WI, United States