A tiny project to post status messages into a specific twitter account.
In this case I am posting to @euskaltantak twitter account basque-spanish translations, but you can change the feed easily.
- If you have a twitter account but you still don't have a Twitter app, create one: (a tutorial here
- Log into your twitter account and go to: https://apps.twitter.com/
- Click on 'Create New App' and fill in Name, Description and Website. (Fallback url is not necessary)
- Enter into your new Twitter App, and go to 'Keys and Access Tokens'.
- Click on 'Generate Consumer Key and Secret' with Read and Write permissions.
- Done. You will need: Consumer Key, Consumer Secret, Access Token and Access Token Secret.
- Project set up is easy:
- git clone git@github.com:xabierlegasa/twitter-junkie-bot.git twitter-junkie-bot
- cd twitter-junkie-bot
- composer install
- cp config/twitter_credentials_EXAMPLE.json config/twitter_credentials.json
- Set correct credentials from step one on config/twitter_credentials.json file
- Post to twitter
- cd web && php post_status_to_twitter.php
You have to implement this simple interface: src/Feed/TwitterFeed.php
<?php
namespace TwitterJunkieBot\Feed;
interface TwitterFeed
{
/** Get a status message to be posted in twitter
* @return string
*/
public function getStatusMessage();
}
In my case, I created: src/Feed/TwitterFeedBasqueDictionary.php which builds a message, from a Basque-Spanish json dictionary. But you can create your own implementation and directly inject it on this class: web/post_status_to_twitter.php