Dockerize

This commit is contained in:
Kai Hendry
2016-08-30 21:53:41 +08:00
parent e363394b90
commit 51e944b455
4 changed files with 18 additions and 56 deletions

View File

@@ -1,50 +1,20 @@
# <http://greptweet.com>
# Greptweet
<a href="http://www.flickr.com/photos/hendry/7577182774/" title="Offline Greptweet on Chrome IOS by Kai Hendry, on Flickr"><img src="http://farm8.staticflickr.com/7133/7577182774_d5b654ea69_n.jpg" width="213" height="320" alt="Offline Greptweet on Chrome IOS"></a>
## Setup
* Image VIRTUAL SIZE <100MB (Docker)
* Uses [HTML offline feature](http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html)
* Aims to [suck less](http://suckless.org) by keeping lines of code low
* Can run from command line
* **Please** review and comment on the code!
Set `access_token` in envfile. You should be able to get it from [creating a new Twitter app](https://dev.twitter.com/apps/new).
# Known limitations
curl -X POST "https://api.twitter.com/oauth2/token" -d "grant_type=client_credentials" -u consumerKey:consumerSecret
* API only allows 3200 tweets to be downloaded this way at one time :(
* 300 API limit using a [Application only Auth](https://dev.twitter.com/docs/auth/application-only-auth) bearer token (which doesn't seem to expire...)
* Won't work on protected accounts (duh!)
* No @mentions or DMs from other accounts
echo 'access_token=secret' > envfile
docker run -d --name greptweet --env-file envfile -p 8888:80 hendry/greptweet
# API
# Maintenance
Invoke a fetch of a TWITTER_USERNAME by accessing the URL:
Running it again:
http://greptweet.com/f/TWITTER_USERNAME
docker start greptweet
Last 4 tweets:
Backing it up:
curl --compressed -s http://greptweet.com/u/webconverger/tweets.txt | head
# Getting a Bearer Token
When you clone and attempt to run this opensource project you will notice that
you are missing a `secret.php` file, this file contains one setting
`$bearer_token`. To [create a bearer
token](https://dev.twitter.com/docs/auth/application-only-auth):
1. [Create a new Twitter app](https://dev.twitter.com/apps/new)
1. Under OAuth settings, make a note of the **Consumer key** and **Consumer secret**
1. Now retrieve the bearer token by building a request with curl:
curl -X POST --verbose "https://api.twitter.com/oauth2/token" -d "grant_type=client_credentials" -u consumerKey:consumerSecret
The response should end like:
{"access_token":"SECRETEXAMPLESTRING","token_type":"bearer"}
Save that SECRETEXAMPLESTRING to www/secret.php:
<?php
$bearer_token = 'SECRETEXAMPLESTRING';
?>
docker cp greptweet:/srv/http/u/ /tmp/backup