Quick and easy way to tweet from a function app
After my last post, I spent some time looking through this. Eventually, I found a really lightweight class which does what i need.
After spending some time adding some error handling to the api.request() method, I then wrapped a webrequest around it and created a function app. You can find it here: https://github.com/mnbf9rca/TwitterFunctionApp
the app takes a simple JSON:
{ “oauth_token“: “<your oAuth token>”, “oauth_token_secret“: “<your oAuth token secret>”, “oauth_consumer_key“: “<your consumer key>”, “oauth_consumer_secret“: “<your consumer secret>”, “tweet”: “<the message to send>” }
You can obtain the oAuth token and oAuth secret by following the instructions on the Twitter Developer site.
The Function App will return a JSON with the data returned by the Twitter API, or an error. Note that as long as it gets SOME response from the Twitter API it’ll return a 200 code. In future I’ll work on making this more granular (e.g. pass through 50x errors).