Skip to content

A Python script that mirrors your Twitter account onto App.net

License

Notifications You must be signed in to change notification settings

dburr/twitter_adn_mirror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Twitter to App.net Crossposter

Version 1.0.1, released 08/02/2013
by Donald Burr dburr@borg-cube.com

ChangeLog

Version 1.0.1, released 08/02/2013
  • Fix handling of boolean values read from config files
Version 1.0.0, released 07/25/2013
  • Initial release

Purpose

This script allows you to crosspost your Twitter posts ("tweets") to the new up-and-coming social network/app platform App.net. It was created because I wanted a quick and simple way to share content to both services. I simply don't have over 9,000 hours in the day to manage all these social networks, nor do I have the patience to do so.

In the past this task could be easily accomplished using a nifty service called If This Then That (IFTTT). However recently Twitter has blocked IFTTT access to the Twitter API, which meant this method would no longer work. I was able to find a different method of piping Twitter data into IFTTT. Unfortunately this method had two downsides: all posts to App.net were prefixed with your Twitter username, and also @mentions and retweets were carried over as well. But it worked well enough for my purposes. Unfortunately, shortly after I discovered it, Twitter deprecated their RSS support, rendering this method non-functional as well.

My latest solution to this problem is this script, which directly calls the Twitter API to read a user's posts. As such it requires you to set up developer accounts with both Twitter and App.net.

Prerequisites

In order to use this script, you will need to install the following Python modules, as well as their prerequisites. Consult their Github pages for instructions on how to do so.

You will also need to set up Developer Accounts with both Twitter and App.net. In the case of Twitter, this is free; however with App.net you will need to pay for a developer account, which costs $100/year.

This script needs to run continuously, so you might want to consider running it under a terminal multiplexer that supports detached sessions such as screen or tmux.

Setup

First, install the above prerequisites. To test if everything is configured properly, run

python mirror.py --help

You should see a help message (and, more importantly, no error or warning messages).

Next, head over to the Twitter developer center, and sign in with your Twitter credentials. At the upper right of the screen should be your user pic; click on it and a pulldown menu will appear. Choose "My Applications," then click "Create a new application." Fill in the requested information (you can use any URLs for both the Website and Callback URL). Once the app has been created, look under "OAuth Settings" and make a note of your "Consumer Key" and "Consumer Secret." On the same page, look for the "Your access token" section, and click "Create my access token." Wait a few minutes then refresh the page. You should now see an "Access token" and "Access token secret" appear; note down those values as well.

Now head on over to the App.net Developer Center and create a new app. Again, you can fill in anything for Website and Callback URL. Once the app is created, scroll down to the "OAuth 2 Settings" section and make a note of the "Client ID" and "Client Secret." Scroll down to the "App Settings" section, and click the "Generate a user token for yourself" link. When asked for the scope, make sure "write post" is checked. Make a note of the token code that has been generated for you.

Now make a copy of config.sample, open it in your favorite text editor, and fill in the requested values.

Finally, run the script with:

python mirror.py -c *config-file*

Some other command-line arguments include:

Usage: mirror [-c | --config=configuration file (default: `mirror.cfg')]
              [-i | --poll-interval=period in secs between polls (default=300)
              [-m | --mirror-mentions]
              [-d | --mirror-indirect-mentions]
              [-r | --mirror-retweets]
              [-u | --user-to-mirror=username to mirror]
              [-n | --simulation-mode]
              [-v | --version]

Note that if an option is specified both in the configuration file as well as a command-line argument, the command-line argument takes precedence.

Future Plans

Some ideas for features/enhancements that I will try and implement.

  • Option to crosspost @mentions if the user being @mentioned also has an account on App.net
  • Mechanism to filter posts, that is, to prevent crossposting of posts that match certain criteria (regexp, client name, etc.) This can be used, for example, to prevent crossposting of automatically generated tweets (from services such as Foursquare, GetGlue, etc.).

If you have any ideas for additinoal features or enhancements, please feel free to open an issue on Github. Or better yet, fork this repo, add the feature/make the change, and submit a pull request.

About the Author

I'm a software engineer-for-hire living and working in the Santa Barbara, California area. I develop in many languages and have published a few apps in the iOS App Store (and soon hopefully the Mac App Store and Google Play as well).

Find out more about me and read my technological musings over at my blog.

I also run a podcast dedicated to Japanese animation (anime) as well as other facets of Japanese pop culture, food, travel, and more. You can find that over at Otaku no Podcast.

Like what you see?

Unfortunately with the economy being the way it is, finding work has been rather difficult, so if you like what you see here and are able to, a small donation would be greatly appreciated.

Donate via PayPal Flattr this git repo

License

This work is licensed under the MIT License.

About

A Python script that mirrors your Twitter account onto App.net

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages