Search code examples
iostumblr

Accessing Tumblr feed using their iOS SDK/API


I'm trying to create a Tumblr application.

It has to be an application for iOS 7. The requirement is to use the TMTumblrSDK but as far as I can see, the documentation is lacking.

I figured out how to use the user authentication but I just can't figure out how to get my own feed.


Solution

  • I finally figured it out. Example:

    NSArray* paramsKeys = [[NSArray alloc] initWithObjects:
                           @"limit",
                           @"offset",
                           @"type",
                           nil];
    NSArray* paramsVals = [[NSArray alloc] initWithObjects:
                           [[NSString alloc] initWithFormat:@"%i", limitNextPage],
                           [[NSString alloc] initWithFormat:@"%i", _dashboardOffsetAudio],
                           @"audio",
                           nil];
    NSDictionary *paramsDict = [[NSDictionary alloc]initWithObjects:paramsVals forKeys:paramsKeys];
    
    [[TMAPIClient sharedInstance]dashboard:paramsDict callback:^(id response, NSError *error){
        if(!error) {
            NSDictionary *dashboard = response;
        }
    }];
    

    Most important part is the static block "sharedInstance". Apparently the whole SDK works with the Tumblr meta data standards. So if you can`t find something that you need you can look into the Tumblr API documentation which explains al the possibilities: https://www.tumblr.com/docs/en/api/v2.

    Explanation:

    • paramsKeys: Those are the keys used in the API. Can be found under "/posts – Retrieve Published Posts".
    • paramsVals: I use it to make a list of array entires.
    • paramsDict: Is to combine the two.
    • sharedInstance: This method is used by the whole application to interact with Tumblr. The dashboard requires the use of above parameters and returns a response object which is just an array of what you request.

      I hope that this will be of help to other.