我在Instagram上使用官方Python Lib。以下是我的代码:
from instagram.client import InstagramAPI
#access token:
#(u'1977729933.05626fd.79e4aa4edf4b48c093bc4b93e116080c',
# {u'username': u'ct.copter', u'bio': u'High definition aerial photography. Based in Greenwich, Connecticut. Flights starting at $99 - real estate, events, curiosity. Warren@ctcopter.com', u'website': u'http://ctcopter.com',
# u'profile_picture': u'https://igcdn-photos-b-a.akamaihd.net/hphotos-ak-xfa1/t51.2885-19/11255033_409200902615593_765355254_a.jpg', u'full_name': u'Greenwich Aerial Photography', u'id': u'1977729933'})
access_token = "1977729933.05626fd.79e4aa4edf4b48c093bc4b93e116080c"
api = InstagramAPI(access_token=access_token)
print(api.user_recent_media())
# recent_media, next_ = api.user_recent_media(user_id="userid", count=10)
# for media in recent_media:
# print media.caption.text
这是错误的:
print(api.user_recent_media())
File "/Library/Python/2.7/site-packages/instagram/bind.py", line 196, in _call
return method.execute()
File "/Library/Python/2.7/site-packages/instagram/bind.py", line 182, in execute
include_secret=self.include_secret)
File "/Library/Python/2.7/site-packages/instagram/oauth2.py", line 224, in prepare_request
url = self._full_url_with_params(path, params, include_secret)
File "/Library/Python/2.7/site-packages/instagram/oauth2.py", line 148, in _full_url_with_params
self._full_query_with_params(params) +
File "/Library/Python/2.7/site-packages/instagram/oauth2.py", line 144, in _full_url
self._signed_request(path, {}, include_signed_request, include_secret))
File "/Library/Python/2.7/site-packages/instagram/oauth2.py", line 172, in _signed_request
return "&sig=%s" % self._generate_sig(path, params, self.api.client_secret)
File "/Library/Python/2.7/site-packages/instagram/oauth2.py", line 127, in _generate_sig
return hmac.new(secret, sig, sha256).hexdigest()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 133, in new
return HMAC(key, msg, digestmod)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 68, in __init__
if len(key) > blocksize:
TypeError: object of type 'NoneType' has no len()
我做错了什么?