twitpic API GSTwitPicEngine错误而setAccessToken [英] twitpic API GSTwitPicEngine error while setAccessToken

查看:251
本文介绍了twitpic API GSTwitPicEngine错误而setAccessToken的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用GSTwitPicEngine类 https://github.com/Gurpartap/GSTwitPicEngine 共享图像在Twitter上搜索
但它给错误

I tried to use GSTwitPicEngine class https://github.com/Gurpartap/GSTwitPicEngine for sharing image on twitter
but its giving error

由于我们要设置 [twitpicEngine setAccessToken:令牌]; 结果
如果我是正确的,我使用 _accessToken 类的<​​code> SA_OAuthTwitterEngine 令牌

As we have to set [twitpicEngine setAccessToken:token];
if I am right, I am using _accessToken of class SA_OAuthTwitterEngine as token

_accessToken 是类中的私有 SA_OAuthTwitterEngine ,我将其设置为公开,也

_accessToken was private in class SA_OAuthTwitterEngine, I set it to public and also

@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与日志

But Application getting crash while setAccessToken with log

-[OAToken parameters]: unrecognized selector sent to instance 0x6327e30
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OAToken parameters]: unrecognized selector sent to instance 0x6327e30'

请帮助,如果你能找到的任何东西错了

Please help if you able to find any thing wrong

阿米特Battan

推荐答案

不幸的是,GSTwitPicEngine没有使用OAuth的消费者,而不是Twitter的神话般+的Oauth库(SAOAuthTwitterEngine)的版本相同。我假设你正在使用的库的消息发布到Twitter。

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.

崩溃是因为OAToken从Twitter +的Oauth doesn't实行参数的方法。

The crash is because OAToken from Twitter+Oauth doesn´t implement the "parameters" method.

今天,我整个上午的时间调整的几个库,以避免崩溃。
在这里,您可以下载我为张贴照片twitpic一个消息叽叽喳喳创建一个示例项目。

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

该项目的所有库的所有最新版本从GitHub。

The project has all the latest versions of all libraries from github.

让我的TestTwitpic项目工作说明:

在TestTwitpic- prefix.pch设置变量:

In TestTwitpic-Prefix.pch set the variables for:

#define kTwitterOAuthConsumerKey @""
#define kTwitterOAuthConsumerSecret @""
#define kTwitPicAPIKey @""

在RootViewController的你可以改变这些行您的需求。要改变照片:

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"];

和这一个改变的消息发送到Twitter:

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"]]];

如果您希望在此基础上样品创建自己的项目。做到以下几点:


  1. 导入到你的项目(拖放)与所有的都在里面的库Twitpic文件夹中。

  2. 这些框架添加到您的项目:

    • CoreGraphics中

    • libz.1.2.3

    • 的libxml2

    • MobileCoreServices

    • SystemConfiguration

    • CFNetwork的

    • 安全

如果你想知道我做了什么固定的图书馆,我会告诉你更多或更少我记得我做过什么:


  1. 导入微博+的Oauth,GSTwitPicEngine,OARequestHeader,TouchJSON和ASIHTT prequest库。

  2. 设置 GSTwitPicEngine 使用 TouchJSON 而不是 YAJL

  3. 新增类别的NSString + URL编码从OAuth的消费GitHub的项目作为 OARequestHeader 失踪了。

  4. 修改里面的NSDictionary *富= [土气参数]中所有出现的 OARequestHeader 与线:

    • 的NSDictionary *富= [NSDictionary的dictionaryWithObject:[令牌键] fo​​rKey:@的oauth_token];

  1. Import Twitter+Oauth, GSTwitPicEngine, OARequestHeader, TouchJSON, and ASIHTTPRequest libraries.
  2. Set GSTwitPicEngine to use TouchJSON instead of YAJL.
  3. Added the category NSString+URLEncoding from oauth-consumer github project as OARequestHeader was missing it.
  4. Modified all occurrences of NSDictionary* foo = [toke parameters] inside OARequestHeader with the line:
    • NSDictionary *foo = [NSDictionary dictionaryWithObject:[token key] forKey:@"oauth_token"];

  • 更改线路:

    • 响应= [[CJSONDeserializer解串器]反序列化:responseString错误:&放大器;错误]

    • change the line:
      • response = [[CJSONDeserializer deserializer] deserialize:responseString error:&error];

      • 响应= [[CJSONDeserializer解串器]反序列化:[responseString dataUsingEncoding:NSUTF8StringEncoding]错误:&放大器;错误]

      • response = [[CJSONDeserializer deserializer] deserialize:[responseString dataUsingEncoding:NSUTF8StringEncoding] error:&error];

      这篇关于twitpic API GSTwitPicEngine错误而setAccessToken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆