0

我正在开发一个 Twitter 应用程序,但在应该是记录的用户信息的视图中,我无法解析由[_engine getUserInformationFor:username];. 我正在使用 SBJSON 并在尝试解析它时告诉我:

2011-05-07 12:29:45.553 BirdieApp[7122:40b] -JSONValue failed. Error is: Unrecognised leading character at offset 0

这是我正在使用的代码:

NSLog(@"loggedapi");
NSString *username = [_engine username];
NSString *userinfo = [_engine getUserInformationFor:username];
NSLog(@"user: %@%@", username, userinfo); NSArray *results = [userinfo JSONValue]; NSDictionary *first = [results objectAtIndex:0]; NSLog(@"screen name = %@", [first objectForKey:@"description"]);
给我的输出[_engine getUserInformationFor:username];是:


2011-05-07 12:29:46.281 BirdieApp[7122:40b] User Info Received: (
        {
        "contributors_enabled" = false;
        "created_at" = "Fri Sep 17 20:40:15 +0000 2010";
        "default_profile" = true;
        "default_profile_image" = false;
        description = "iPhone developer and Photoshop designer. \U30dd\U30fc\U30eb. I developed a web browser, it's called zad0xNET browser, search it in Cydia. Ofcourse this is a fake account!";
        "favourites_count" = 0;
        "follow_request_sent" = false;
        "followers_count" = 4;
        following = 0;
        "friends_count" = 1;
        "geo_enabled" = true;
        id = 191964939;
        "is_translator" = false;
        lang = es;
        "listed_count" = 0;
        location = "Castilla y Le\U00f3n, Espa\U00f1a";
        name = zad0xLOL;
        notifications = false;
        "profile_background_color" = C0DEED;
        "profile_background_image_url" = "http://a3.twimg.com/a/1304019356/images/themes/theme1/bg.png";
        "profile_background_tile" = false;
        "profile_image_url" = "http://a0.twimg.com/profile_images/1190671091/ProfilePhoto_normal.png";
        "profile_link_color" = 0084B4;
        "profile_sidebar_border_color" = C0DEED;
        "profile_sidebar_fill_color" = DDEEF6;
        "profile_text_color" = 333333;
        "profile_use_background_image" = true;
        protected = 0;
        "screen_name" = zad0xs1s;
        "show_all_inline_media" = true;
        "source_api_request_type" = 12;
        status =         {
            contributors = "";
            coordinates = "";
            "created_at" = "Sat May 07 07:42:18 +0000 2011";
            favorited = false;
            geo = "";
            id = 66769811828514816;
            "in_reply_to_screen_name" = zad0xs1s;
            "in_reply_to_status_id" = "";
            "in_reply_to_user_id" = 191964939;
            place = "";
            "retweet_count" = 0;
            retweeted = false;
            source = "BirdieApp";
            "source_api_request_type" = 12;
            text = "@zad0xs1s sdjdjdd";
            truncated = 0;
        };
        "statuses_count" = 16;
        "time_zone" = Madrid;
        url = "http://www.pabloxweb.es";
        "utc_offset" = 3600;
        verified = false;
    }

我认为它是 JSON,但不确定。我也尝试使用 twitter 提供的 url,但也没有工作。URL 是http://api.twitter.com/1/users/show.json?screen_name=zad0xsis,其中“zad0xsis”是 Twitter 用户名。

提前致谢!!;)

4

2 回答 2

1

嗨。这是一个很好的链接OAuth Twitter

此示例使用模型在 NSDictionary 中获取 json 结果。他们调用了 getUsertimeLine 方法。你可以调用你自己的方法。

于 2011-05-07T12:32:50.293 回答
0

我对 Cocoa 和 JSON 的体验是

  • 它只是无法正常工作...
  • 或者解析它不值得所有麻烦!

使用 Twitter XML API 可能会更好

https://api.twitter.com/1/users/show.xml?screen_name=zad0xsis

然后使用 NSXMLParser 解析它(在 iPhone 上): http: //ll.io/e17

或者

NSXMLDocument (Mac): http://ll.io/ff0

希望这可以帮助!

于 2011-05-07T11:44:38.940 回答