Ever since we launched our Flickr2Twitter beta, developers have been requesting new API methods, so they can support Flickr as a photo sharing option in their Twitter clients.
I’ve got good news, and bad news.
The bad news is we don’t have any new APIs to offer you.
The good news is we shipped our “Twitter APIs” nearly five years ago.
Let me explain.
Working with Blogs (including Twitter)
For as long as anyone can remember, we’ve supported the option of posting to external blogs directly from Flickr. Once you’ve conﬁgured a blogging service it becomes available in the “Blog This” drop down, as an option for Upload by Email, and, of course, in the API.
You and I might have serious philosophical questions about whether Twitter is a blogging service, but our web servers are more pragmatic. To them, the Twitter integration is just a new blogging service.
Configuring a blogging service
Twitter is a bit special (or rather a preview of things to come) as we’ve given it its own service page. Directing users of your app to the Flickr2Twitter page is probably the best way get them “tweet ready”.
From here on out, you’ll need your user to have authorized you to access their Flickr account. (Find out more about FlickrAuth)
With a signed call to flickr.blogs.getList() you can get a list of all the blogging services a member has configured. Alternately you can pass in a
service id (e.g.
<blogs> <blog id="7214" name="Code Flickr" service="MetaWeblogAPI" needspassword="0" url="http://code.flickr.com/blog/"/> <blog id="7215" name="Twitter: kellan" service="Twitter" needspassword="0" url="http://twitter.com/kellan"/> <blog id="72157" name="Twitter: Flickr" service="Twitter" needspassword="0" url="http://twitter.com/flickr"/> </blogs>
This account has 3 blogs configured. A WordPress blog, and two Twitter accounts. Each one has a unique id. Additionally
needpassword="0" means we have credentials for these blogs stored server side and you don’t need to prompt your user to log in to their blog.
If you passed in
Then your user hasn’t configured any blogs for that service.
The Easy Option: Upload a photo to Flickr, post to Twitter via Flickr
If your application has been authorized to upload photos on your user’s behalf, and you’ve made sure they have a Twitter blog configured with Flickr, then the easiest solution is to use Flickr as a passthru service.
blog id from the
<blogs> list above, and the
photoid from the upload response to flickr.blogs.postPhoto(). If you’re posting to Twitter the
title argument is optional and the
description argument is ignored. (By default the title of the photo is the body of the tweet, alternately pass a different status update in the
Or instead of passing a blog id, you can pass a service id (i.e.
Blog not found.” error.
The Established Option: Upload a photo Flickr, post to Twitter any which way you can
If you’re looking to integrate Flickr photos into an existing Twitter application you might already have a preferred method for posting to Twitter.
Unlike most URL shortening schemes, every photo on Flickr already has a short URL associated with it. The follow the form:
By the way, you shouldn’t feel constrained to only use short urls on Twitter. They work equally well for a diverse range of applications including fortune cookies.
If you want to display a thumbnail of a photo, you’ll need to make an API call to one of the methods that returns the photo’s secret. Either flickr.photos.getSizes() or flickr.photos.getInfo() will do. Read up on constructing Flickr URLs.
My favorite new game has been watching the flows of shared Flickr photos as they appear on Twitter.
Happy photo sharing!