# statie.yaml
parameters:
twitter_name: 'TomasVotruba'
# how many days to wait before publishing another Tweet - set 0 days for testing
twitter_minimal_gap_in_days: 1
# how old Tweets should be tweeted, to prevent 2-years old posting
twitter_maximal_days_in_past: 60
- Get Twitter Access Tokens
- Go to apps.twitter.com/app/new
- Login under account you want to publish in and create new Application
- Then go to "Keys and Access Tokens"
- In the bottom click to "Create my access token"
- Put them to
statie.yml.local
config:
# statie.yml.local
parameters:
twitter_consumer_key: 'TgnmCuTSH7gftcWOaFBUXPZzH'
twitter_consumer_secret: '9oenODoyFsF2mG3zNevUY4HPwG76zGQBTBoWzfHUKCIorR2lJ0'
twitter_oauth_access_token: '2463691352-mAMTJjo6kowEYddGTPpqdjUTWueQwWrLUdHpB9O'
twitter_oauth_access_token_secret: 'ltb12xYHdWAHrtPWm5h31T6Rptfa1IyutensM5EsX47Dt'
Never share them publicly, if you don't want to have child porn tweets under your name.
- Add
statie.yaml.local
tostatie.yaml
# statie.yml
+imports:
+ - { resource: 'statie.yml.local', ignore_errors: not_found }
- Add it to
.gitignore
so it's secret
+statie.yml.local
Write "tweet" in your post.
id: 252
title: 'How to Learn Playing Drums from 0'
tweet: 'New post on my blog: How to Learn Playing Drums from 0 #music'
# optional, relative path
tweet_image: '/assets/images/posts/drums.jpg'
---
It's a long journey...
And test it
vendor/bin/statie tweet-post
Is it there? Good, it works and only few steps remain to fully automate this :)
Now we only put that logic on Travis and we're done.
-
Open Travis for your repository, e.g. https://travis-ci.org/TomasVotruba/tomasvotruba.com
-
Got to More options => Settings
-
In Environment Variables add 4 variables with they values. They are hidden by default, so don't worry:
TWITTER_CONSUMER_KEY
TWITTER_CONSUMER_SECRET
TWITTER_OAUTH_ACCESS_TOKEN
TWITTER_OAUTH_ACCESS_TOKEN_SECRET
-
Then setup cron, so posts are being published even if you don't write and have a break.
-
Go to Cron Jobs →
master
branch → Daily → Always run → Add -
Let
.travis.yml
know, that he should publish it
# .travis.yml
language: php
matrix:
include:
- php: 7.3
env: TWEET=1
script:
# tweets posts
- if [[ $TRAVIS_BRANCH == "master" && $TRAVIS_PULL_REQUEST == "false" && $TWEET != "" ]]; then vendor/bin/publish-new-tweet; fi
- Now you can quit Twitter if you want and you posts will be still there :)