class API(object):
def __init__(self, auth_handler=None, username=None, host='twitter.com', cache=None,
- secure=False, classes={'user': User, 'status': Status,
+ secure=False, api_root='', classes={'user': User, 'status': Status,
'direct_message': DirectMessage, 'friendship': Friendship,
'saved_search': SavedSearch, 'search_result': SearchResult}):
self.auth_handler = auth_handler
self.username = username
self.host = host
+ self.api_root = api_root
self.cache = cache
self.secure = secure
self.classes = classes
def _call(api, *args, **kargs):
# If require auth, throw exception if credentials not provided
- if not api.auth_handler:
+ if require_auth and not api.auth_handler:
raise TweepError('Authentication required!')
# build parameter dict
# Build url with parameters
if parameters:
- url = '%s?%s' % (path, urllib.urlencode(parameters))
+ url = '%s?%s' % (api.api_root + path, urllib.urlencode(parameters))
else:
- url = path
+ url = api.api_root + path
# get scheme and host
if api.secure: