|
Cookbook /
TwitterPostSummary: easily post updates to your Twitter account via PHP functions
Version: 2009-08-03
Prerequisites:
Status: not currently working, as of Summer 2010 - twitter has switched to OAuth - recipe to hopefully be updated soon
Maintainer: overtones99
Download: twitterposts.phpΔ
Questions answered by this recipe
Descriptioneasily post updates to your Twitter account via PHP functions. NotesThis code allows an admin to easily post updates to a Twitter account. Simply call the following function with the appropriate username, password, and a message: ... and that's it - your status update is sent. I am currently using this function in coordination with a cron job that calls the code daily, and sends tweets listing any newly created pages. (By updating at the end of the day, as opposed to immediately after a page has been posted, visitors are less likely to be directed to a page still-under-construction, and allows the editor to set up PTV's to be included in the tweet, i.e. This recipe was developed using code posted on Gareth Rushgrove's website, http://morethanseven.net/2007/01/20/posting-to-twitter-using-php/. Note that there are apparently many more Twitter API libraries out there that allow all sort of interaction with Twitter, but this was the simplest, most straightforward code for simply sending updates that I found while sleuthing around. Feel free to explore those as well, and feel free to improve this code, update this page, etc... InstallationSimply download twitterposts.phpΔ, and add the following lines to your ## POST TO TWITTER # Set username and password $twitter_username = 'yourUsername'; $twitter_password = 'yourPassword'; # turns on "URL shortening"via bit.ly - # see the relatedBit.Ly Cookbook Recipe Suggested ImplementationThe basic call, from config.php or any other PHP function you devise, is simply:
There are likely several ways this function can be used - perhaps messages can be sent via a public or private comment box? The way I've been using it is to schedule a daily cron job to send updates to Twitter, listing any new pages that have been created in the last 24 hours; the cron job simply calls
In addition, Twitter'ers are used to using and seeing shortened URL's. If you're also fond of these, then you might want to enable the Short Urls recipe, and set Release notes
See also
Contributors
CommentsUser notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki. |