Stream feed from Twitter to Azure Event Hub
Project description
# TwitterEventHubFeed
A command line tool that allow to stream feed from Twitter to EventHub.
This project is a fork of the [TwitterCosmosDBFeed](https://github.com/tknandu/TwitterCosmosDBFeed) by [tknandu](https://github.com/tknandu)
## Pre-requisites
- (1) Registration as a Twitter App
- You need to register the tool as a new application at <http://apps.twitter.com/>. After choosing a name and application for your app, you will be provided with a *twitter_consumer_key*, *twitter_consumer_secret*, *twitter_access_token* and *twitter_access_token_secret* - which need to be filled into *twitter2eh.json* to provide the app programmatic access to Twitter.
- (2) Create an Event Hub
- You need to create a namespace for the Event Hubs type, and obtain the management credentials that your application needs to communicate with the event hub. To create a namespace and event hub, follow the procedure in this document - [Create an Event Hubs namespace and an event hub using the Azure portal](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create)
## Getting Started
Install the package [twitter2eh](https://test.pypi.org/project/twitter2eh/) using pip:
```
pip install twitter2eh
or
sudo pip install twitter2eh
```
## Usage
```
twitter2eh -h
usage: twitter2eh [-h] [-v] [--init] [-c CONF] [-s]
This program streams feed from Twitter to EventHub
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--init Create template client conf twitter2eh.json only if
there is no existing one
-c CONF, --conf CONF twitter2eh configuration file. Default:twitter2eh.json
-s, --silent silent mode - running the tool without displaying tweets json that you are streaming to your Event Hub
```
## Configuration file - twitter2eh.json
In order to run the tool, you need to configure a configuration file for the tool and specify the file in running the tool.
```
{
"twitter_consumer_key" : "<Consumer Key for Twitter App>",
"twitter_consumer_secret" : "<Consumer Secret for Twitter App>",
"twitter_access_token" : "<Access Token for Twitter App>",
"twitter_access_secret" : "<Access Secret for Twitter App>",
"track_keywords" : [
"<Keyword or Hashtag>",
"<Keyword or Hashtag>",
"<Keyword or Hashtag>"
],
"eventhub_namespace" : "<Event Hub Namespace>",
"eventhub_entity" : "<Event Hub Entity Name>",
"eventhub_sas_key" : "<Event Hub SAS Key Name>",
"eventhub_sas_value" : "<Event Hub SAS Value>"
}
```
Please refer to [example configuration file](twitter2eh.json.example) and run the tool like this:
```
% twitter2eh --conf ./twitter2eh.json
```
Or run with `-s|--silient` option if you want to run the tool without displaying tweets json that you're streaming to your Event Hub
```
% twitter2eh --conf ./twitter2eh.json --silent
```
A command line tool that allow to stream feed from Twitter to EventHub.
This project is a fork of the [TwitterCosmosDBFeed](https://github.com/tknandu/TwitterCosmosDBFeed) by [tknandu](https://github.com/tknandu)
## Pre-requisites
- (1) Registration as a Twitter App
- You need to register the tool as a new application at <http://apps.twitter.com/>. After choosing a name and application for your app, you will be provided with a *twitter_consumer_key*, *twitter_consumer_secret*, *twitter_access_token* and *twitter_access_token_secret* - which need to be filled into *twitter2eh.json* to provide the app programmatic access to Twitter.
- (2) Create an Event Hub
- You need to create a namespace for the Event Hubs type, and obtain the management credentials that your application needs to communicate with the event hub. To create a namespace and event hub, follow the procedure in this document - [Create an Event Hubs namespace and an event hub using the Azure portal](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create)
## Getting Started
Install the package [twitter2eh](https://test.pypi.org/project/twitter2eh/) using pip:
```
pip install twitter2eh
or
sudo pip install twitter2eh
```
## Usage
```
twitter2eh -h
usage: twitter2eh [-h] [-v] [--init] [-c CONF] [-s]
This program streams feed from Twitter to EventHub
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--init Create template client conf twitter2eh.json only if
there is no existing one
-c CONF, --conf CONF twitter2eh configuration file. Default:twitter2eh.json
-s, --silent silent mode - running the tool without displaying tweets json that you are streaming to your Event Hub
```
## Configuration file - twitter2eh.json
In order to run the tool, you need to configure a configuration file for the tool and specify the file in running the tool.
```
{
"twitter_consumer_key" : "<Consumer Key for Twitter App>",
"twitter_consumer_secret" : "<Consumer Secret for Twitter App>",
"twitter_access_token" : "<Access Token for Twitter App>",
"twitter_access_secret" : "<Access Secret for Twitter App>",
"track_keywords" : [
"<Keyword or Hashtag>",
"<Keyword or Hashtag>",
"<Keyword or Hashtag>"
],
"eventhub_namespace" : "<Event Hub Namespace>",
"eventhub_entity" : "<Event Hub Entity Name>",
"eventhub_sas_key" : "<Event Hub SAS Key Name>",
"eventhub_sas_value" : "<Event Hub SAS Value>"
}
```
Please refer to [example configuration file](twitter2eh.json.example) and run the tool like this:
```
% twitter2eh --conf ./twitter2eh.json
```
Or run with `-s|--silient` option if you want to run the tool without displaying tweets json that you're streaming to your Event Hub
```
% twitter2eh --conf ./twitter2eh.json --silent
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
twitter2eh-0.2.0.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file twitter2eh-0.2.0.tar.gz
.
File metadata
- Download URL: twitter2eh-0.2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8b835a59160d86de1a037ce78dadce7750d5fe8c9690c931799c3869c081132 |
|
MD5 | 55a2aebfd6af3bd606e94fcb1194c3c2 |
|
BLAKE2b-256 | 587b9df89e6693d2b5162d77bbaffc81beb1e5388e7adb010e9dc4958c2f5e35 |
File details
Details for the file twitter2eh-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: twitter2eh-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 902f6d9cfb44c3340d05ede2a17abc494b8f1e2001803b932e2d03ffa43e065a |
|
MD5 | acdceaf0dbde13f076d2b36e725a0b81 |
|
BLAKE2b-256 | d7b025850c51dd5263ddd5d18a86cdf98e612392bf02f8942c2fffa4e710c119 |