问题
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