24 Jul, 2009 in Programming by

.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

2 Responses so far | Have Your Say!

  1. Wavatar

    Kamal Salem  |  October 8th, 2011 at 2:43 pm #

    I’m trying to use your library, I don’t want to upload photos, I just need to download them, however, when I try using the code above, I can’t find the class ImageLoader, any ideas?

  2. Wavatar

    Roger  |  October 10th, 2011 at 3:28 pm #

    Hi Kamal, the ImageLoader class referenced above is just a dummy class that doesn’t exist. It’s just showing that some local object is reading an image file into a byte array. A real option would be System.IO.File.ReadAllByes(“path:\to\file.ext”).

    Second, this class library is exclusively used for UPLOADING imaages and doesn’t provide any downloading features. Sorry for the inconvenience.

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>