This is what I have written for the get_users function. I guess I'm just confused about how this specific endpoint works.
def get_users(twitter, screen_names):
"""Retrieve the Twitter user objects for each screen_name.
twitter = get_twitter()
users = get_users(twitter, ['twitterapi', 'twitter'])
[u['id'] for u in users]
[6253282, 783214]
"""
request = robust_request(twitter, 'users/lookup', screen_names)
screen_names = []
for r in request:
screen_names.append(r)
return sorted(screen_names)
running this ($ nosetests --with-doctest a0.py:get_users)
I get:
Failed example:
users = get_users(twitter, ['twitterapi', 'twitter'])
Exception raised:
Traceback (most recent call last):
File "/home/david/anaconda3/lib/python3.5/doctest.py", line 1321, in __run
compileflags, 1), test.globs)
File "<doctest get_users[1]>", line 1, in
users = get_users(twitter, ['twitterapi', 'twitter'])
File "/home/david/Desktop/davidghiurco/a0/a0.py", line 118, in get_users
request = robust_request(twitter, 'users/lookup', screen_names)
File "/home/david/Desktop/davidghiurco/a0/a0.py", line 91, in robust_request
request = twitter.request(resource, params)
File "/home/david/anaconda3/lib/python3.5/site-packages/TwitterAPI/TwitterAPI.py", line 131, in request
proxies=self.proxies)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 461, in request
prep = self.prepare_request(req)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 394, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/models.py", line 298, in prepare
self.prepare_body(data, files, json)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/models.py", line 452, in prepare_body
body = self._encode_params(data)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/models.py", line 89, in _encode_params
for k, vs in to_key_val_list(data):
ValueError: too many values to unpack (expected 2)
Too many values to unpack? Huh? What exactly do I get back from making this request?
This is what I have written for the get_users function. I guess I'm just confused about how this specific endpoint works.
def get_users(twitter, screen_names): """Retrieve the Twitter user objects for each screen_name.
running this ($ nosetests --with-doctest a0.py:get_users) I get: Failed example: users = get_users(twitter, ['twitterapi', 'twitter']) Exception raised: Traceback (most recent call last): File "/home/david/anaconda3/lib/python3.5/doctest.py", line 1321, in __run compileflags, 1), test.globs) File "<doctest get_users[1]>", line 1, in
users = get_users(twitter, ['twitterapi', 'twitter'])
File "/home/david/Desktop/davidghiurco/a0/a0.py", line 118, in get_users
request = robust_request(twitter, 'users/lookup', screen_names)
File "/home/david/Desktop/davidghiurco/a0/a0.py", line 91, in robust_request
request = twitter.request(resource, params)
File "/home/david/anaconda3/lib/python3.5/site-packages/TwitterAPI/TwitterAPI.py", line 131, in request
proxies=self.proxies)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 461, in request
prep = self.prepare_request(req)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/sessions.py", line 394, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/models.py", line 298, in prepare
self.prepare_body(data, files, json)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/models.py", line 452, in prepare_body
body = self._encode_params(data)
File "/home/david/anaconda3/lib/python3.5/site-packages/requests/models.py", line 89, in _encode_params
for k, vs in to_key_val_list(data):
ValueError: too many values to unpack (expected 2)
Too many values to unpack? Huh? What exactly do I get back from making this request?