Search code examples
objective-cpostfetchtumblr

Display Tumblr Posts in iPhone


How can I display tumblr blog posts on an app just like how the mobile version shows it instead of loading the URL on a UIWebView?


Solution

  • yes use http://www.tumblr.com/docs/en/api

    The api allows you to read the tumblr page and phrase the information you wish to display. This will require you to write your own xml phaser class, but theres a bunch of tutorials out there.

    Reading Tumblr data is easy: just fetch the page at http://YOU.tumblr.com/api/read and you'll get a structured XML version of your content in this format...

    The api even has an example of using objective-c with tumblr to log in

    NSString *email           = @"example@email.com";
    NSString *password        = @"password";
    NSString *destination_url = @"/iphone";
    
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]
        initWithURL:[NSURL URLWithString:@"https://www.tumblr.com/login"]
    ];
    [request setHTTPMethod:@"POST"];
    NSString *request_body = [NSString 
        stringWithFormat:@"email=%@&password=%@&redirect_to=%@",
        [email           stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
        [password        stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
        [destination_url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
    ];
    [request setHTTPBody:[request_body dataUsingEncoding:NSUTF8StringEncoding]];
    /* Load the request here with an NDA-covered iPhone component
       that can view the web.
    */
    [request release];