24 Jul, 2009 in Programming by Roger

.NET library for Twitpic photo API

Twitpic .NET API I needed to integrate an application into Twitpic for uploading pictures related to a Tweet.

So after spending a few hours reading over there API spec, I’ve created a simple class library for accessing Twitpics 2 remote calls:

Class Twitpic:

public Twitpic(byte[] media, string twitterUsername, string twitterPassword)
public TwitpicResponse UploadAndPost(string message)
public TwitpicResponse Upload()

Here’s a simple example using this class:

/* how you get an image to bytes is up to you */
ImageLoader img = new ImageLoader();
byte[] imageBits = img.ReadImage(thumbUrl);
/* i'm just downloading an image into a byte[] in this example */
 
Twitpic tp = new Twitpic(imageBits, AppSettings.TwitterUsername, AppSettings.TwitterPassword);
TwitpicResponse resp = tp.Upload();
 
imgThumb.ImageUrl = resp.MediaUrl;

In this simple example, I’m downloading an image off the web into a byte array. That array will be uploaded to Twitpic and if successful, you’ll get a TwitpicResponse which provides properties to access this uploaded image. Otherwise a TwitpicException may be raised indicating the error response received from the Twitpic API.

Download Twitpic.NET v1.0.

Please provide any feedback in the comments below!

Share on Twitter

No Responses so far | Have Your Say!

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Twee60, created by Roger Dickey