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:
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!