Giter VIP home page Giter VIP logo

twitivity's Introduction

Twitivity

PyPI - Python Version PyPI - License

Twitter Accounts Activity API Client Library for Python

  • ๐Ÿ”‘ Performs CRC validation
  • ๐Ÿ“ Registers webhooks
  • ๐Ÿ”‰ Subscribes to current user's context
  • ๐ŸŽง Gets activities of the user in real time.

Usage

Refer to Twitter's getting started guide on how to create an application. Then set up dev environment label for the application.

Credentials

App โžก๏ธ Details โžก๏ธ Keys and Tokens

Add the credentials to the environment variables.

~$ export consumer_key=API_KEY
~$ export consumer_secret=API_SECRET_KEY
~$ export access_token=ACCESS_TOKEN
~$ export access_token_secret=ACCESS_TOKEN_SECRET
~$ export env_name=APP_ENV_NAME

Install & run ngrok.

~$ ./ngrok http 5000 

Stream events in real time.

# stream_events.py

>>> from twitivity import Event
>>> import json

>>> class StreamEvent(Event):
     CALLBACK_URL: str = "https://yourdomain.com/listener"
    
     def on_data(self, data: json) -> None:
         # process data

>>> stream_events = StreamEvent()
>>> stream_events.listen()

Setup

To register the callback URL run the program above alongside the one below. This will register your webhook URL and subscribe to activities. This only has to be setup once.

# configure.py

from twitivity import Activity

>>> account_activity = Activity()
>>> account_activity.register_webhook("https://youdomain.com/listener")
>>> account_activity.subscribe()

The registration will return json response

{
    'id': '1198870971131686912', # webhook id
    'url': 'https://1f4396a1.ngrok.io/twitter/callback', 
    'valid': True, 
    'created_timestamp': '2019-11-25 07:48:08 +0000'
}

Installation

~$ pip install twitivity

twitivity's People

Contributors

saadmanrafat avatar

Stargazers

MD AYAT ULLAH avatar

Watchers

James Cloos 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.