'Instantiate a new twitter.Api object.
Args:
consumer_key:
Your Twitter user\'s consumer_key.
consumer_secret:
Your Twitter user\'s consumer_secret.
access_token_key:
The oAuth access token key value you retrieved
from running get_access_token.py.
access_token_secret:
The oAuth access token\'s secret, also retrieved
from the get_access_token.py run.
input_encoding:
The encoding used to encode input strings. [Optional]
request_header:
A dictionary of additional HTTP request headers. [Optional]
cache:
The cache instance to use. Defaults to DEFAULT_CACHE.
Use None to disable caching. [Optional]
base_url:
The base URL to use to contact the Twitter API.
Defaults to https://api.twitter.com. [Optional]
use_gzip_compression:
Set to True to tell enable gzip compression for any call
made to Twitter.  Defaults to False. [Optional]
debugHTTP:
Set to True to enable debug output from urllib2 when performing
any HTTP requests.  Defaults to False. [Optional]
timeout:
Set timeout (in seconds) of the http/https requests. If None the
requests lib default will be used.  Defaults to None. [Optional]'

def __init__(self, consumer_key=None, consumer_secret=None, access_token_key=None, access_token_secret=None, input_encoding=None, request_headers=None, cache=DEFAULT_CACHE, base_url=None, stream_url=None, upload_url=None, chunk_size=(1024 * 1024), use_gzip_compression=False, debugHTTP=False, timeout=None, sleep_on_rate_limit=False):

    self.SetCache(cache)
    self._cache_timeout = Api.DEFAULT_CACHE_TIMEOUT
    self._input_encoding = input_encoding
    self._use_gzip = use_gzip_compression
    self._debugHTTP = debugHTTP
    self._shortlink_size = 19
    self._timeout = timeout
    self.__auth = None
    self._InitializeRequestHeaders(request_headers)
    self._InitializeUserAgent()
    self._InitializeDefaultParameters()
    self.rate_limit = None
    self.sleep_on_rate_limit = sleep_on_rate_limit
    if (base_url is None):
        self.base_url = 'https://api.twitter.com/1.1'
    else:
        self.base_url = base_url
    if (stream_url is None):
        self.stream_url = 'https://stream.twitter.com/1.1'
    else:
        self.stream_url = stream_url
    if (upload_url is None):
        self.upload_url = 'https://upload.twitter.com/1.1'
    else:
        self.upload_url = upload_url
    self.chunk_size = chunk_size
    if (self.chunk_size < (1024 * 16)):
        warnings.warn('A    chunk    size    lower    than    16384    may    result    in    too    many    requests    to    the    Twitter    API    when    uploading    videos.    You    are    strongly    advised    to    increase    it    above    16384')
    if ((consumer_key is not None) and ((access_token_key is None) or (access_token_secret is None))):
        print("Twitter    now    requires    an    oAuth    Access    Token    for    API    calls.    If    you're    using    this    library    from    a    command    line    utility,    please    run    the    included    get_access_token.py    tool    to    generate    one.", file=sys.stderr)
        raise TwitterError({'message': 'Twitter    requires    oAuth    Access    Token    for    all    API    access'})
    self.SetCredentials(consumer_key, consumer_secret, access_token_key, access_token_secret)
    if debugHTTP:
        import logging
        import http.client
        http.client.HTTPConnection.debuglevel = 1
        logging.basicConfig()
        logging.getLogger().setLevel(logging.DEBUG)
        requests_log = logging.getLogger('requests.packages.urllib3')
        requests_log.setLevel(logging.DEBUG)
        requests_log.propagate = True
