是否有可能绕过推文对话框直接发布到Twitter? [英] Is it possible to bypass the tweet dialog and post directly to twitter?

查看:121
本文介绍了是否有可能绕过推文对话框直接发布到Twitter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ShareKit来实现Twitter共享。我有一个带有textview的视图控制器,并希望在绕过推文输入对话框时将该文本发送到ShareKit中的帖子。

I am using ShareKit to implement Twitter share. I have a view controller with a textview and would like to send that text to the post in ShareKit while bypassing the tweet input dialog.

SHKItem *item = [SHKItem text:[postText text]];
[SHKTwitter shareItem:item];

如果没有登录,上面的代码会对用户进行身份验证,然后获取我的文本并填充ShareKits tweet对话框。挖掘他们的代码让我感到困惑。有没有人能够成功地将推文文本直接发布到Twitter?

The code above authenticates the user if not logged in, then takes my text and populates ShareKits tweet dialog. Digging through their code has confused the heck out of me. Has anyone been able to successfully post the tweet text directly to twitter?

推荐答案

首先,创建一个 SHKTwitter 并授权用户:

First, create an instance of SHKTwitter and authorize the user:

twitter = [SHKTwitter new];
[twitter authorize];

然后,一旦用户获得授权,请设置项目并发送。

Then once the user is authorized, set up the item and send.

SHKItem *item = [SHKItem new];
[item setCustomValue:@"i am tweeting" forKey:@"status"];
twitter.item = item;
[twitter send];

status自定义值是特定的到 SHKTwitter 类。您需要对 SHKItem 执行其他操作才能与其他共享者一起使用。例如这适用于 SHKFacebook

The "status" custom value is specific to the SHKTwitter class. You need to do other things to SHKItem for it to work with other sharers. e.g. this works with SHKFacebook:

item.shareType = SHKShareTypeText;
item.text = "hi";

这篇关于是否有可能绕过推文对话框直接发布到Twitter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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