OLBTwitpicEngine is a simple controller class for uploading a UIImage to TwitPic.com and post a message containing it to Twitter.
This class was created back in 2008 when the iPhone was new and hot,
and Twitter apps -- and especially Twitter frameworks -- were nonexistent.
Though I haven't used this class for a few years, my strong feeling is that it won't
work at all partly due to Twitter's full switch to OAuth2
(which is great), which this code doesn't
support.
Of course nowadays you wouldn't want to use classes like this at all. The built-in Twitter.framework
in iOS 5+ is what's fresh, and uses Twitter's own image hosting
service. (TwitPic was the hot thing back then, believe you me.) This class is merely offered for
historical curiosity.
Disclaimer: This code reflects a tiny part of my output mid-2008, when I was a few months in to using the Cocoa Touch frameworks. It hasn't been changed since then--apart from being somewhat cleaned up for presentation--and doesn't have much of the structure or API usage I would utilize today. Please don't hold it against me :)
-
Import the
OLBTwitpicEngine.h
header file into your controller class. -
Download and import the
RegexKitLite
library and its dependencies (get it here). It's used for parsing the TwitPic post URL from the XML response we get back. -
Get and import the singleton macro from Cocoa with love. This is a simple macro for generating a single version of the OLBTwitpicEngine object to be shared.
-
Set the
delegate
in your Controller and implement theOLBTwitpicEngineDelegate
protocol. -
Call the
uploadImageToTwitpic:withMessage:username:password:
method and send along theUIImage
, the user's Twitterusername
andpassword
, as well as themessage
text to post alongside the TwitPic link in the final tweet. -
Respond to the
delegate
method callback when the thread is done uploading (or has failed doing so). -
Profit!
This code is offered under the MIT License.
Copyright (c) 2008-2012 Oskar Boethius Lissheim (@avocade on Twitter).
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.