Showing posts with label twitter. Show all posts
Showing posts with label twitter. Show all posts

Tuesday, June 17, 2014

How to Make Your Very Own DPLA Twitter Bot

When I saw that @HistoricalCats had launched as part of DPLA’s very nice App Library, I was a bit surprised that it wasn’t followed by a ton of other DPLA Twitter Bots. I had heard other people comment on the lack of a @HistoricalDogs twitter bot and thought that this would be a good project for me to try, especially since the examples in the @HistoricalCats source code pointed out the need for equal feline and canine representation. I thought I would write up my experiences adapting @HistoricalDogs for anyone else who needs a recipe to follow when adapting @HistoricalCats. Maybe we will soon see @HistoricalHats or @HistoricalBirds next!

Skills you need to do this:
I’m not a computer programmer, but I have some basic web administrative skills. I’ve installed mysql and php applications on a web server before. If you’re comfortable with doing some light editing (basically just copying and pasting) of php files it is easy to set up a twitter bot with the @HistoricalCats code that is provided. I did it in an hour or so one evening after work.

Things you need:

  • Web server space
  • A text editor
  • FTP program
  • Knowledge of how to set up cron jobs (optional)
First step: Get accounts and keys
Second step: Get all the files!

The Code for Historical Cats is available on GitHub (https://github.com/malantonio/HistoricalCats), just download the master zip file and open it.
Wow, that was fast and easy!

Third step: Modify the files for your new twitter bot and upload to your server space

Follow the instructions (https://github.com/malantonio/HistoricalCats) for modifying the historicalcat.php file and the keys.config.php files, adding in your own DPLA API key and Twitter consumer key, secret, access token, and access secret. If you look at the source code, you can see the cat phrases and the search terms that you can change to whatever you wish.


These are the only areas that you might need to modify in order to get your bot up and working. If you chose to, you can set up a sql database that will save your tweets and prevent tweet duplication. I didn’t set this up as part of my process, but if you have access to phpMyAdmin or something similar on your server, you can easily import the provided HistoricalCat.sql structure to a new database on your server. If you are using the database option when installing the code, you will also need to put this information into your config file.

Now you’re ready to upload the files! You should ftp these files up to your web server space. Note that you need to upload the twitteroath folder as well as historicalcat.php, config.php, and tweetcat.php to make everything run.


Visit http://yourwebsite.org/tweetcat.php to generate your first automatic tweet! If you don’t see any error messages you will see a tweet appear on your new twitter bot account. I didn’t have any problems getting this set up, except I needed to slightly adjust the filepath for twitteroath due to the way I uploaded my files. If you get error messages, they will specify the line of code in the file where the problem is. Most text editors will let you zero in on the line number where the problem is so you can do some troubleshooting.

Now, you could generate tweets automatically by just pointing your web browser at tweetcat.php whenever you want a post to appear, but if you want your twitter bot to run automatically, you will need to set up a cron job, so the page is just automatically visited at whatever times you want your tweets to be posted. Your web host may have some additional tools you can use to easily create a cron job for your new twitter bot.

Happy tweeting!!!!

Thanks very much to Adam Malantonio for creating the @HistoricalCats code, and for giving me feedback on this blog post.

Monday, March 10, 2014

Twitter! What is it Good for!?

Even though twitter has been around what seems like forever in Internet time, I sometimes find myself explaining why it is useful to non-twitter users. I have a couple twitter accounts that I use for different reasons.
  • A personal twitter account (see if you can use your librarian super powers to find it). I joined twitter when I saw many of my online friends join it too! I use this account to tweet about non-library pursuits. This is a way for me to stay in touch with some of my friends, as well as follow along with tweets about my hobbies. A few years ago some of my friends and I launched a satirical twitter account that got a book deal, so I feel like my 15 minutes of Internet Fame also were due to twitter. 
  • A professional twitter account - I was a bit hesitant about setting up a more professional twitter account as part of my job with MWDL, but I ended up finding it really useful. I use this account to take notes on some of the conferences I've been to in the form of live tweeting, which would probably be fairly obnoxious if I did it on my personal account where my followers aren't used to getting that type of information from me. I've followed many people who work in digital libraries and digital preservation on my professional twitter account, so I've found it to be really useful as a system to alert me to articles published in the subject areas I'm interested in as well as some of the more informal conversations about library issues that pop up frequently on twitter. I also like to follow the twitter accounts from digital libraries that are similar to MWDL, as well as MWDL partners. I went from worrying that having two regular twitter accounts would be too much, to being happy that I use both accounts for different purposes. 
One other reason why I like twitter is that it isn't Facebook! I think I only have the attention span to be fully engaged in one social media platform at a time, and I much prefer twitter over Facebook, just because I enjoy the short form of the updates, easily being able to retweet things I find interesting, and it is much easier to track conversations through twitter like this one about OrphanWorks or LAMfutures

Do you follow MWDL on twitter?