Okay, so you’re unlikely to use Iguana to connect to twitter, but Twitter’s API is a useful example of implementing the OAuth 1.0 protocol, in this case using HMAC signing.
This example requires Iguana 6.0.3 or above since it uses the built in crypto APIs which were included in that release of Iguana.
Now you tweet all your key healthcare events to the world… or not.
Tip: The code for this channel uses stores the the Twitter login information (consumer_key, consumer_secret, access_token, token_secret) in plain text this is not best practice.
You can use the encrypt.password.lua and store2.lua modules to store logon information in encrypted format, see the Salesforce.com Adapter for an example of how to do this.
Setup Twitter [top]
- Create a Twitter account for development:
- Go to https://apps.twitter.com and sign in
- Click “Create New App” button
- Click on the “Keys and Access Tokens” tab to get the Twitter credentials you need
- Paste the Twitter credentials into the demo channel:
Using the Code [top]
- Import the OAuth 1.0 with Twitter channel from the Builtin: Iguana Webservices repository
- Experiment with the code to find out how it works
- Then add the modules to your Translator project
- Copy the require statement from the channel and add it at the top of your script
Note: The twitter.api.lua module uses require to return a table
Note: The oauth.oauth.lua module uses require to return a table
- Adapt the code to your own requirements
- Interactive scripting help is included for this module
This is the github code for the main module:
How it works [top]
It uses the Twitter API implementation the OAuth 1.0 protocol with HMAC signing.
This example also uses the built-in Iguana crypto APIs, so it requires Iguana 6.0.3 or above.