Twiter DIA Example
From Digi Developer
You should register at www.etherios.com/devicecloud and then download DIA. After that, read the Getting Started guide and begin looking at the simple drivers (found under ../src/devices in the DIA source code tree). You should have a basic working knowledge of DIA(how to start / stop & use basic drivers / presentations) before proceeding.
This demo requires the tweepy python library. Tweepy can be found here: https://github.com/joshthecoder/tweepy
Register a new twitter application by going to http://twitter.com/apps/new. When you submit the form, you will be presented with a page that shows your consumer key and consumer secret. Take note of these.
Download the following archive Media:Twitter_Dia.zip, unzipping its contents within the src/presentations directory of the DIA. Add the following to your yml config file (by default this will be the cfg/dia.yml) and change the settings accordingly, or remove the optional settings.
presentations: - name: twitter driver: presentations.twitter.updater:Updater settings: interval: 60 status_template: "uploaded from the iDigi Dia: %s" sample_template: "%s=%s" channels: [template.counter, template.adder_reg1]
Here is a breakdown of the different options:
interval optional How often to "tweet". If this setting does not exist it will default to 180 seconds status_template optional Format of the tweet, with a %s where to put the sample data. If left blank this will default to "iDigi Dia Update: %s" sample_template optional Format of the samples, two %ss required, first for the channel name, second for sample value. defaults to "%s:%s" channels optional List of channels the module is subscribed to. defaults to all channels
Re-compile DIA incorporating the above elements under presentations of the cfg/dia.yml file. You can do this via the command line (python make.py dia.yml) or using the Digi IDE for DIA.
Run the DIA When it's running, the first thing you will be asked for is your consumer key. Enter the consumer key that was shown when you registered the twitter app. You will then be asked to enter your consumer secret. Do the same as before.
Next, you will see a prompt that says Please verify URL: followed by a long URL. Type that URL into your browser and search for it. You will see a twitter page that asks whether you want to allow the application to connect to your twitter account. Click Allow.
You will then be presented with a PIN. This is the PIN you must enter into the command prompt.
Once you enter the PIN, DIA will begin tweeting to your account!
If DIA fails with an error message "No module named gopherlib" followed by "global name 'twitter' is not defined" The reason could be that the module gopherlib is excluded in the DIA build process. Please adjust the file tools\digi_build_zip.py and comment out the gopherlib line like:
# Other things that can get in the way, and don't seem likely #"gopherlib", #"ftplib", "pydoc",