Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 894
Oh Danny Boy Avatar asked Jan 26 '11 21:01

Oh Danny Boy


1 Answers

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";
like image 118
gak Avatar answered Nov 05 '22 09:11

gak