MCPcopy Index your code
hub / github.com/ryanmcgrath/twython / construct_api_url

Method construct_api_url

twython/api.py:433–461  ·  view source on GitHub ↗

r"""Construct a Twitter API url, encoded, with parameters :param api_url: URL of the Twitter API endpoint you are attempting to construct :param \*\*params: Parameters that are accepted by Twitter for the endpoint you're requesting :rtype: string Usa

(api_url, **params)

Source from the content-addressed store, hash-verified

431
432 @staticmethod
433 def construct_api_url(api_url, **params):
434 r"""Construct a Twitter API url, encoded, with parameters
435
436 :param api_url: URL of the Twitter API endpoint you are attempting
437 to construct
438 :param \*\*params: Parameters that are accepted by Twitter for the
439 endpoint you're requesting
440 :rtype: string
441
442 Usage::
443
444 >>> from twython import Twython
445 >>> twitter = Twython()
446
447 >>> api_url = 'https://api.twitter.com/1.1/search/tweets.json'
448 >>> constructed_url = twitter.construct_api_url(api_url, q='python',
449 result_type='popular')
450 >>> print constructed_url
451 https://api.twitter.com/1.1/search/tweets.json?q=python&result_type=popular
452
453 """
454 querystring = []
455 params, _ = _transparent_params(params or {})
456 params = requests.utils.to_key_val_list(params)
457 for (k, v) in params:
458 querystring.append(
459 '%s=%s' % (Twython.encode(k), quote_plus(Twython.encode(v)))
460 )
461 return '%s?%s' % (api_url, '&'.join(querystring))
462
463 def search_gen(self, search_query, **params): # pragma: no cover
464 warnings.warn(

Callers 1

Calls 2

_transparent_paramsFunction · 0.85
encodeMethod · 0.80

Tested by 1