I have a web app registered in Twitter and so have an app ID. I want to use that to publish content from the website to the users’ timeline (on their behalf, their own content). I have it working on the server side but I’d like to know the way with jQuery to do it on client side.
Share
With jQuery, use the jQuery.post() method. Something like this should work:
This is assuming that on the server side your script is named
myTwitterUpdater.phpand it accepts the status update in a parameter namedstatus. Add your own authentication mechanisms as additional parameters or something on top of that, if you need that. The server should then use the Twitter REST API and more precisely its POST statuses/update resource to forward your status update to Twitter. (You said you got it working already, but for anyone else interested, just Google for “twitter oauth php example“, or substitute PHP with your language of choice.)Twitter’s OAuth-authentication is best left for the server to handle. It’s difficult to do with JavaScript but not impossible.