Giter VIP home page Giter VIP logo

cat-pics's Introduction

Cat pics!

Resources for Tweeting cat pictures.

Tutorial: Tweeting Media with v2 of the Twitter API in Python

With the launch of the manage Tweets endpoint, we included the ability to attach previously uploaded media to a Tweet. In addition, based on feedback we’ve heard from you, we recently added access to the v1 media endpoints for all users.

Code that corresponds to this tutorial can be found in the folder v2-media-tutorial in this repository.

This tutorial will walk you through how to Tweet images of cats using the manage Tweets endpoint of v2 and the v1.1 media endpoints in Python using Flask. Using OAuth 2.0. Authorization Code Flow with PKCE to request the Manage Tweets endpoint requires a user to log in. Therefore, you can use Flask as a web framework to parse the information dynamically.

Before you start

Before you start, you must install the required packages for this script, including requests for making HTTP requests to various endpoints, tweepy for working with OAuth 1.0a, requests_oauthlib for working with OAuth 2.0, and flask as a web framework.

pip install requests tweepy requests_oauthlib flask

In your terminal, you will want to define the following environment variables:

export CLIENT_ID=’xxxxxxxxxxxxxx’
export CLIENT_SECRET=’xxxxxxxxxxx’
export REDIRECT_URI=’http://127.0.0.1:5000/oauth/callback’
export API_KEY=’xxxxxxxxxxxxxx’
export API_SECRET=’xxxxxxxxxxx’
export ACCESS_TOKEN=’xxxxxxxxxxx’
export ACCESS_TOKEN_SECRET=’xxxxxxxxxxx’

You can obtain your own OAuth 2.0 Client ID and Secret inside of the developer settings in the developer portal.

You will want to use your own credentials found in the Developer Portal instead of of the value xxxxxxxxxxxxxx.

Factual cat image support

@FactualCat is a bot that Tweets cat facts and now images using the code in the folder factual-cat-image-support. You will need to run gsd.py once locally to log in. After that you can use every_other.py to Tweet regularly.

This code is currently deployed to Render using redis and a cron job to run twice daily.

cat-pics's People

Stargazers

LZ91X  avatar  avatar  avatar Mauricio Menegaz avatar Black Pjotr avatar

Watchers

James Cloos avatar Carmen Yuen avatar kyle | kbw.eth avatar Nimo avatar Amir Shevat avatar @snowman avatar Juan Shishido avatar  avatar John Demos avatar Juan Luna avatar John Babich avatar  avatar

Forkers

hgsk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.