iphone MGTwitterEngine - post a tweet with my app signature

我怕爱的太早我们不能终老 提交于 2019-12-18 17:07:57

问题


I'm using MGTwitterEngine in an iPhone app, and it works great. The one thing I want to change is the "posted from MGTwitterEngine" that appears on Twitter. Obviously I'd like it to say "from MyCoolApp", and link to the app's website.

When you register an app with Twitter (http://twitter.com/oauth_clients/create), you get this info:

* Consumer key
  ***a891tcxSvL6QpEeo12g
* Consumer secret
  ***MqeRIXiWsecretAdAjCgFsBN7Lef12f3uyxJFrs
* Request token URL
  http://twitter.com/oauth/request_token
* Access token URL
  http://twitter.com/oauth/access_token
* Authorize URL
  http://twitter.com/oauth/authorize

Where do you input this information in the current release of MGTwitterEngine?


回答1:


You can find detailed information on how to do this in the Readme: http://svn.cocoasourcecode.com/MGTwitterEngine/README.txt

You mentioned that you already received your token, so the next step would be to call the method

- (void)setClientName:(NSString *)name version:(NSString *)version URL:(NSString *)url token:(NSString *)token;

on your MGTwitterEngine instance.




回答2:


From Twitters new FAQ for applications

If you would like tweets from your application to recieve a source parameter, please register an application and implement OAuth authentication. We will automatically include your application as the source for any tweets sent from your application.

We originally allowed applications to create a source paramter for non-OAuth use but that has been discontinued. Applications pre-OAuth source parameters will remain active, but new registrations are no longer accepted.

So it looks as if you're gonna have to be doing some work!




回答3:


I was able to get it to work using this demo by Ben Gottlieb:

http://github.com/bengottlieb/Twitter-OAuth-iPhone

Do a search for REPLACE ME and you will able to find where you need to input your consumer key & secret.

The user has to grant your app permission via the Twitter website so it's a bit ugly when you run it the 1st time but it works. I don't know of any alternatives at present - hopefully Twitter will update the process soon. You only have to do the ugly OAuth authentication once. After that, this line:

[_engine sendUpdate: [NSString stringWithFormat: @"Already Updated. %@", [NSDate date]]];

will post an update to your twitter account that should be appended with "from MyCoolApp".



来源:https://stackoverflow.com/questions/1064970/iphone-mgtwitterengine-post-a-tweet-with-my-app-signature

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!