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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:41:31+00:00 2026-05-13T08:41:31+00:00

Im trying to parse twitter trends but i keep getting a parser error at

  • 0

Im trying to parse twitter trends but i keep getting a parser error at “as_of”. anyone know why this is happening?

EDIT:

Here is the code im using

NSMutableArray *tweets;
tweets = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:@"http://search.twitter.com/trends/current.json"];
trendsArray = [[NSMutableArray alloc] initWithArray:[CCJSONParser objectFromJSON:[NSString stringWithContentsOfURL:url encoding:4 error:nil]]]; 

NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];

for (int i = 0; i < [trendsArray count]; i++) {
    dict = [[NSMutableDictionary alloc] init];
    //[post setObject: [[currentArray objectAtIndex:i] objectForKey:@"query"]];
    [dict setObject:[trendsArray objectAtIndex:i] forKey:@"trends"];
    //[dict setObject:[trendsArray objectAtIndex:i] forKey:@"query"];
    //[post setObject:[trendsArray objectAtIndex:i] forKey:@"as_of"];
    [tweets addObject:dict];
    //post = nil;
}
  • 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-13T08:41:31+00:00Added an answer on May 13, 2026 at 8:41 am

    I’m not exactly sure what your problem could be but I’ve had a play with the twitter api and CCJSON and have got some sample code that seems to work. If you cut and paste it into the applicationDidFinishLaunching method of a new project and include the CCJSON files it will just work (hopefully).

    This code will take the trends json from twitter, output the as_of value and create an array of trends.

    // Make an array to hold our trends
    NSMutableArray *trends = [[NSMutableArray alloc] initWithCapacity:10];
    
    // Get the response from the server and parse the json
    NSURL *url = [NSURL URLWithString:@"http://search.twitter.com/trends/current.json"];
    NSString *responseString = [NSString stringWithContentsOfURL:url encoding:4 error:nil];
    NSDictionary *trendsObject = (NSDictionary *)[CCJSONParser objectFromJSON:responseString]; 
    
    // Output the as_of value
    NSLog(@"%@", [trendsObject objectForKey:@"as_of"]);
    
    // We also have a list of trends (by date it seems, looking at the json)
    NSDictionary *trendsList = [trendsObject objectForKey:@"trends"];
    
    // For each date in this list
    for (id key in trendsList) {
        // Get the trends on this date
        NSDictionary *trendsForDate = [trendsList objectForKey:key];
    
        // For each trend in this date, add it to the trends array
        for (NSDictionary *trendObject in trendsForDate) {
            NSString *name = [trendObject objectForKey:@"name"];
            NSString *query = [trendObject objectForKey:@"query"]; 
            [trends addObject:[NSArray arrayWithObjects:name, query, nil]];
        }
    }
    
    // At the point, we have an array called 'trends' which contains all the trends and their queries.
    // Lets see it . . .
    for (NSArray *array in trends)
        NSLog(@"name: '%@' query: '%@'", [array objectAtIndex:0], [array objectAtIndex:1]);
    

    Hope this is useful, comment if you have any questions,

    Sam

    PS I used this site to visualise the JSON response – it made it much easier to see what is going on – I just cut and paste the JSON from twitter into it 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 292k
  • Answers 292k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you make a control that is inherited from Control,… May 13, 2026 at 6:11 pm
  • Editorial Team
    Editorial Team added an answer What you want to do is non-trivial! I have done… May 13, 2026 at 6:11 pm
  • Editorial Team
    Editorial Team added an answer I'd suggest sticking with the non-beta version (2.3). Chances are… May 13, 2026 at 6:11 pm

Related Questions

I'm trying to parse a twitter feed in django, and I'm having a strange
So I'm trying to parse some XML from the twitter API and for some
I'm building a little Twitter thing in PHP and I'm trying to parse URLs,
This is my first question :). Im writing a little twitter app in PHP
I'm having a problem parsing a JSON file in AS3. Im trying to parse

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.