<jupyter_start><jupyter_text>Example 1. Authorizing an application to access Twitter account data<jupyter_code>import twitter
python -m pip install twitterscraper
from setuptools import setup, find_packages
import csv
import json
import argparse
import collections
import datetime as dt
from os.path import isfile
# XXX: Go to http://dev.twitter.com/apps/new to create an app and get values
# for these credentials, which you'll need to provide in place of these
# empty string values that are defined as placeholders.
# See https://dev.twitter.com/docs/auth/oauth for more information on Twitter's OAuth implementation.
# access_token = "<KEY>"
# access_token_secret = "<KEY>"
# consumer_key = "<KEY>"
# consumer_secret = "<KEY>"
CONSUMER_KEY ="<KEY>"
CONSUMER_SECRET ="<KEY>"
OAUTH_TOKEN ="<KEY>"
OAUTH_TOKEN_SECRET ="<KEY>"
auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET,CONSUMER_KEY, CONSUMER_SECRET)
twitter_api = twitter.Twitter(auth=auth)

# Nothing to see by displaying twitter_api except that it's now a defined variable

print (twitter_api)
type(twitter)
dir(twitter)
help(twitter)
## Example 1. Accessing Twitter's API for development purposes
import twitter

def oauth_login():
    # XXX: Go to http://twitter.com/apps/new to create an app and get values
    # for these credentials that you'll need to provide in place of these
    # empty string values that are defined as placeholders.
    # See https://dev.twitter.com/docs/auth/oauth for more information 
    # on Twitter's OAuth implementation.
    
    CONSUMER_KEY ="5rEhPV8THryOeTmDVVHi03axp"
    CONSUMER_SECRET ="<KEY>"
    OAUTH_TOKEN ="<KEY>"
    OAUTH_TOKEN_SECRET ="<KEY>"
    
    auth = twitter.oauth.OAuth(OAUTH_TOKEN, OAUTH_TOKEN_SECRET, CONSUMER_KEY, CONSUMER_SECRET)
    
    twitter_api = twitter.Twitter(auth=auth)
    return twitter_api
# Sample usage
twitter_api = oauth_login()    

# Nothing to see by displaying twitter_api except that it's now a defined variable

print (twitter_api)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0872583044124938, 'fraction_numerical': 0.002974714923153198, 'mean_word_length': 4.88338192419825, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '311212', 'license': 'MIT', 'n_tokens_mistral': 676, 'n_tokens_neox': 644, 'n_words': 205, 'path': 'TwitterUsingTwitter.ipynb', 'repo_name': 'Farshid123/Old-Win-7', 'size': '2447'}