Code Monkey home page Code Monkey logo

twitter-filtered-stream-client's Introduction

Twitter Filtered Stream API Client

A simple Go program to consume Twitter's filtered stream API.

Settings

This program depends on two environment variables to work (you can copy .env.sample as .env as well):

  • TWITTER_API_KEY
  • TWITTER_API_SECRET

There are also two optional environment variables:

  • TWITTER_APP_NAME which is the name of your Twitter application (used as user-agent in the API requests)
  • TWITTER_ACCESS_TOKEN which is highly recommended since Twitter discourage you to use the endpoint that grants this token (read further on to know how to get this token using this client)

Usage

You can either run the commands with go run main.go or calling the binary generated with go build main.go.

1. Get your OAuth2 token

$ go run main.go token

This command displays the token to be used for authentication. It's highly recommended to save this value as an environment variable called TWITTER_ACCESS_TOKEN (or save it in your .env).

2. Start to listen to the stream

$ go run main.go stream

This command starts to listen to the stream of tweets. Start this program in an instance of the terminal and then move to another instance to create your rules โ€“ and wait to see the magic! Once a tweet matches the rules you create in the next step, it will be saved in the data/ directory.

3. Manage your rules

$ go run main.go rule ls

This command lists the existing rules for the filtered stream.

$ go run main.go rule new --query YOUR-SEARCH-TERM-HERE

This command creates a new rule using the text passed with the --query option.

$ go run main.go rule rm

This command deletes all existing rules.

Contributing

I'm still learning Go, so any feedback, issue, comment or pull request is welcome!

I know we have libraries to handle the requests to Twitter API, but this bare implementation was a way I've found to study net/http, ok?

twitter-filtered-stream-client's People

Contributors

cuducos avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.