# Quick and easy way to tweet from a function app

https://blog.cynexia.com/twitter-bot-as-a-function-app

Author: [Rob Aleck](https://blog.cynexia.com/pages/about) · https://github.com/mnbf9rca · https://www.linkedin.com/in/robertaleck/ · https://family-foqos.app/

Published: 2016-10-19
Categories: How-to


After my last post, I spent some time looking through this. Eventually, I found a really [lightweight class](<https://gist.github.com/sdesalas/c82b92200816ecc83af1>) 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](<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](<https://web.archive.org/web/20161019220335/https://dev.twitter.com/oauth/overview/application-owner-access-tokens>).

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).

