Using ADNpy To Make ADN Posts From The Command Line

Using ADNpy To Make ADN Posts From The Command Line

ADN announced ADNpy today. It’s a Python library for accessing App.net. The GitHub page has an example for making a post, and I expanded on it a little so I can make posts from the command line. I’d been using the awesome Texapp for doing this, but for my uses, that was extreme overkill. This script is much lighter.

#!/usr/bin/python
import sys
import adnpy

if len(sys.argv) == 1 :
    print "none"
    sys.exit(0)

adnpy.api.add_authorization_token('YOUR_ACCESS_CODE_HERE')
post, meta = adnpy.api.create_post(data={'text':sys.argv[1]})

I saved mine as adn, so calling it is pretty simple:

# adn "message to post"

The quotes are important. The script checks sys.argv. If you didn’t supply an argument, it silently exits. Otherwise, it posts your message, which is whatever is contained within the quotes.

    Related Posts