Is it possible to bypass the tweet dialog and post directly to twitter?

元气小坏坏 提交于 2019-11-29 09:56:35

问题


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

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?


回答1:


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

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


来源:https://stackoverflow.com/questions/4810146/is-it-possible-to-bypass-the-tweet-dialog-and-post-directly-to-twitter

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