5

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?

Oh Danny Boy
  • 4,857
  • 8
  • 56
  • 88
  • I would not recommend doing this. People tend to hate apps that post to Twitter without asking them first. Why do you want to bypass this dialog? – Lily Ballard Jan 26 '11 at 21:27
  • 4
    I dont want to autopost. I want to use my skinned view vs the very plain text input dialog in ShareKit. There is a post button in the view. – Oh Danny Boy Jan 31 '11 at 15:58
  • It's sometimes necessary or much easier to do this in the app flow. For example on Pinterest you get the tweet sheet if you share an existing pin, but if you have twitter sharing toggled while you are adding a new photo it tweets directly. – mahalie Aug 02 '12 at 19:12

1 Answers1

6

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";
gak
  • 32,061
  • 28
  • 119
  • 154
  • Is it possible to bypass the tweet dialog and post directly to facebook? – Steve Gear Jun 08 '11 at 08:38
  • i tried the above , but not work for facebook ..can u plz give me the code – Steve Gear Jun 08 '11 at 08:39
  • how to the image to both facebook and twitter directly. – Steve Gear Jun 08 '11 at 08:40
  • 1
    @Chakradhar, to post an image you can set `shareType` to `SHKShareTypeImage`. I haven't tried this so you should investigate the ShareKit source code on how it's done internally. Also, for your other questions, if it doesn't work for you, set the sharer `shareDelegate` variable to a class you control and see what errors are reported. – gak Jun 08 '11 at 20:25
  • @Gerald I tried your code but it doesn't work for me.. any clue please i am using latest one – vinothp Aug 10 '12 at 17:26