我尝试使用GSTwitPicEngine类https://github.com/Gurpartap/GSTwitPicEngine在twitter上共享图像。
但它的给予错误
因为我们必须设置[twitpicEngine setAccessToken:token];
如果我是对的,我将使用_accessToken of class SA_OAuthTwitterEngine作为标记。
_accessToken在SA_OAuthTwitterEngine类中是私有的,我把它设置为公共的,并且
@property (nonatomic, readonly) OAToken *accessToken;
@synthesize accessToken = _accessToken;然后在行动中
twitPicEngine = [GSTwitPicEngine twitpicEngineWithDelegate:self];
[twitPicEngine setAccessToken:twitterObj.accessToken];
[twitPicEngine uploadPicture:[shareDict objectForKey:@"image"] withMessage:[shareDict objectForKey:@"image_msg"]];但是应用程序在使用日志时setAccessToken会崩溃
-[OAToken parameters]: unrecognized selector sent to instance 0x6327e30
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OAToken parameters]: unrecognized selector sent to instance 0x6327e30'如果你发现有什么不对的地方,请帮忙
Amit Battan
发布于 2011-04-29 13:45:56
不幸的是,GSTwitPicEngine并没有使用与Twitter+Oauth库(SAOAuthTwitterEngine)相同的oauth消费者版本。我想你是在用这个库把消息发到twitter上。
崩溃是因为来自OAToken的Twitter+Oauth没有实现“参数”方法。
今天,我花了整整一个上午的时间对几个库进行了调整,以避免崩溃。在这里,您可以下载我创建的一个示例项目,它是为了在twitter上发布带有消息的twitpic照片而创建的。
TestTwitpic
该项目拥有来自github的所有库的所有最新版本。
关于如何使我的项目工作的说明
在TestTwitpic-前缀中,for为以下变量设置变量:
#define kTwitterOAuthConsumerKey @""
#define kTwitterOAuthConsumerSecret @""
#define kTwitPicAPIKey @""在RootViewController中,您可以根据需要更改这些行。若要更改照片:
//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"];而这一条将改变发送给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"]]];如果您想要基于此示例创建您自己的项目,请使用。执行以下操作:
如果您想知道我为修复库做了什么,我会或多或少地告诉您我记得我做了什么:
GSTwitPicEngine设置为使用TouchJSON而不是YAJL。NSDictionary *foo = [NSDictionary dictionaryWithObject:[token key] forKey:@"oauth_token"];
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.
发布于 2012-10-12 04:50:00
您可以在从twitter引擎获得之后,为twitpic设置访问令牌和访问秘密。
SA_OAuthTwitterEngine.m
在"SA_OAuthTwitterEngine.m“中创建"GSTwitPicEngine.m”类的对象&将访问令牌和访问秘密传递给"GSTwitPicEngine.m“,并在"SA_OAuthTwitterEngine.m”中设置"GSTwitPicEngine.m“的委托方法。
再换一次..。
必须交叉检查URLEncoding,同时对OAuth标头进行分类。
requestHeader generateRequestHeaders
这将根据Twitter库中的"OAuthConsumer“类进行。
https://stackoverflow.com/questions/5591562
复制相似问题