Ad

Our DNA is written in Swift
Jump

DTXMLRPC 1.0

Just a week ago I started DTXMLRPC as a means to post to my WordPress blog from QuickRadar. Somebody took a liking to it and sponsored me to continue work on it. So I implementing the remaining data types for XML-RPC serialization and improved the demo by adding a demonstration how to upload an image to WordPress.

The DTWordpress class, based on DTXMLRPC, provides an ever growing number of WordPress API calls, like retrieving a user’s blogs, a blog’s categories, posting a new article and uploading an image. All is block based.

For example this is the code in the sample app for uploading an image:

- (IBAction)uploadImage:(id)sender {
    DTWordpress *wordpress = [[DTWordpress alloc] initWithEndpointURL:URL];
    wordpress.userName = user;
    wordpress.password = pass;
 
    UIImage *image = [UIImage imageNamed:@"Default"];
    NSData *imageData = UIImageJPEGRepresentation(image, 0.8);
 
    [wordpress newMediaObjectWithFileName:@"bla.jpg" 
        contentType:@"image/jpeg" 
        data:imageData 
        shouldOverwrite:YES 
        completion:^(NSInteger mediaID, NSURL *mediaURL, NSError *error) {
        // deal with result
        });
    }];
}

DTXMLRPC is available as Open Source project for free use with attribution. A non-attribution license is also available on our store.


Tagged as:

Categories: Updates

Leave a Comment