Unfortunately, GSTwitPicEngine is not using the same version of oauth-consumer than the fabulous Twitter+Oauth library (SAOAuthTwitterEngine). I assume you are using that library for posting messages to twitter.
The crash is because OAToken from Twitter+Oauth doesn´t implement the "parameters" method.
Today I spent the entire morning tweaking the several libraries to avoid crashes.
Here you can download a sample project I created for posting a twitpic photo to twitter with a message.
TestTwitpic
The project has all the latest versions of all libraries from github.
Instructions for making my TestTwitpic project work:
In TestTwitpic-Prefix.pch set the variables for:
#define kTwitterOAuthConsumerKey @""
#define kTwitterOAuthConsumerSecret @""
#define kTwitPicAPIKey @""
In RootViewController you can change these lines to your needs. To change the photo:
//change [UIImage imageNamed:@"image.jpg"] for whatever UIImage you want to upload
//change @"my photo" for whatever title you want for your photo in twitpic website
[twitpicEngine uploadPicture:[UIImage imageNamed:@"image.jpg"] withMessage:@"my photo"];
and this one to change message sent to twitter:
//I post to twitter the title of the photo and the twitpic url but you can post whatever you want
[engine sendUpdate:[NSString stringWithFormat:@"%@ %@", [[[response objectForKey:@"request"] userInfo] objectForKey:@"message"], [[response objectForKey:@"parsedResponse"] objectForKey:@"url"]]];
If you want to create your own project based on this sample. Do the following:
- Import into your project (drag and drop) the Twitpic folder with all the libraries that are inside.
- Add these frameworks to your project:
- CoreGraphics
- libz.1.2.3
- libxml2
- MobileCoreServices
- SystemConfiguration
- CFNetwork
- Security
- In Build Settings add "$SDKROOT/usr/include/libxml2" to the "Header Search Paths" (mark it as recursive)
- In Build Settings add -lxml2 to "Other linker flags"
If you want to know what I did for fixing the libraries, I will tell you more or less what I remember I did:
- Import Twitter+Oauth, GSTwitPicEngine, OARequestHeader, TouchJSON, and ASIHTTPRequest libraries.
- Set
GSTwitPicEngine
to use TouchJSON
instead of YAJL
.
- Added the category NSString+URLEncoding from oauth-consumer github project as OARequestHeader was missing it.
- Modified all occurrences of NSDictionary* foo = [toke parameters] inside OARequestHeader with the line:
NSDictionary *foo = [NSDictionary dictionaryWithObject:[token key] forKey:@"oauth_token"];
- Created a method getAccessToken in SAOAuthTwitterEngine to return the private _accessToken variable.
- In requestFinished: inside GSTwitPicEngine
- change the line:
response = [[CJSONDeserializer deserializer] deserialize:responseString error:&error];
- with the line:
response = [[CJSONDeserializer deserializer] deserialize:[responseString dataUsingEncoding:NSUTF8StringEncoding] error:&error];
- as GSTwitPicEngine wrongly assumed deserialize:error: method accepts an NSString instead of an NSData.