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

匿名 (未验证) 提交于 2019-12-03 02:06:01

问题:

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


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