This is for a couple of reasons:
- The free level of developer account access does not provide any API access for reading tweets. 100 USD/month to read a few tweets makes no economic sense.
- The python-twitter library does not support the Twitter v2 API.
Unfortunately this project is no longer viable, and it has been abandoned.
digestsforthought is a small app to send an e-mail containing a small selection of tweets from selected Twitter accounts. If there are some accounts that you want to read regularly, but can't find amongst the other tweets, you may find this useful.
It's intended to be run daily, e.g.: using AWS Lambda. You may find it useful for chosing some tweets to read at breakfast.
- Create a Twitter account.
- Register a Twitter app at [https://apps.twitter.com/].
- Create a new app.
- Generate an API key for your new app with read-only permissions.
- Make a note of your Twitter consumer API key and secret, and the Twitter access key and secret.
- Create a SparkPost account [https://app.sparkpost.com/sign-up]
- Set up a Sending Domain, and verify it.
- Create an API key with permissions to send a transmission (Transmissions write permission).
- Make a note of your SparkPost API key.
This project is managed using Pipenv. You will likely need to install Pipenv first.
Once pipenv is installed, you can install all the pre-requisites and start a shell in a Python virtualenv using the following steps. The Python virtualenv makes development easier by using a version of Python set up with all the pre-requiste modules and tools:
pipenv install --dev --python /usr/bin/python3
pipenv shell
The pipenv setup includes the AWS command-line tool. If you exit the pipenv shell, you can always restart it using pipenv shell
.
cp config.json.sample config.json
# Edit config.json
digestsforthought defaults to using SparkPost US. If you would like to use SparkPost EU, make sure that your config.json
file contains the following line:
"sparkpost_base_uri": "https://api.eu.sparkpost.com",
./digestsforthought
TODO
TODO: Note that the commands below fail because cloudformation does not support the Zipfile property on Lambda. Need to upload the CFN template and ZIP to S3, then use them in CFN template.
TODO: Parameterise bucket name, since they need to be globally unique
aws s3 mb s3://digestsforthought
aws s3 cp cfn/digestsforthought.yaml s3://digestsforthought
aws s3 cp digestsforthought.zip s3://digestsforthought
aws cloudformation create-stack --stack-name digestsforthought2 --template-body "$(cat cfn/digestsforthought.yaml)" --parameters ParameterKey=FunctionName,ParameterValue=digestsforthought2 --capabilities CAPABILITY_IAM
aws cloudformation wait stack-create-complete --stack-name digestsforthought2
aws cloudformation update-stack --stack-name digestsforthought2 --template-body "$(cat cfn/digestsforthought.yaml)" --parameters ParameterKey=FunctionName,ParameterValue=digestsforthought2 --capabilities CAPABILITY_IAM
Copyright 2017-2020 Richard Dawe
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.