Python Instagram API - API requests fail -


i learning how use instagram api through python-instagram package. have setup clients, have client id , client secret. have gotten access token using get_access_token.py script in python-instagram, reason getting error:

traceback (most recent call last):    file "<ipython-input-38-6440f86cbefd>", line 1, in <module>     runfile('f:/pythonprojects/minefield/instagram test.py', wdir='f:/pythonprojects/minefield')    file "c:\anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 580, in runfile     execfile(filename, namespace)    file "f:/pythonprojects/minefield/instagram test.py", line 13, in <module>     api.user_search(q='samsungmobile')    file "c:\anaconda\lib\site-packages\instagram\bind.py", line 196, in _call     return method.execute()    file "c:\anaconda\lib\site-packages\instagram\bind.py", line 182, in execute     include_secret=self.include_secret)    file "c:\anaconda\lib\site-packages\instagram\oauth2.py", line 224, in prepare_request     url = self._full_url_with_params(path, params, include_secret)    file "c:\anaconda\lib\site-packages\instagram\oauth2.py", line 148, in _full_url_with_params     self._full_query_with_params(params) +    file "c:\anaconda\lib\site-packages\instagram\oauth2.py", line 144, in _full_url     self._signed_request(path, {}, include_signed_request, include_secret))    file "c:\anaconda\lib\site-packages\instagram\oauth2.py", line 172, in _signed_request     return "&sig=%s" % self._generate_sig(path, params, self.api.client_secret)    file "c:\anaconda\lib\site-packages\instagram\oauth2.py", line 127, in _generate_sig     return  hmac.new(secret, sig, sha256).hexdigest()    file "c:\anaconda\lib\hmac.py", line 136, in new     return hmac(key, msg, digestmod)    file "c:\anaconda\lib\hmac.py", line 71, in __init__     if len(key) > blocksize:  typeerror: object of type 'nonetype' has no len() 

and here code:

from instagram.client import instagramapi access_token = '1********4.0*****5.fb1c**********39***7365*********' api = instagramapi(access_token=access_token) api.user_search(q='samsungmobile') 

the script fails when calling last line api.user_search(q='samsungmobile') have no idea how typeerror got raised, suspect may have access token.

i using correct one. get_access_token.py script returns tuple of length 2, first index contains access token string, second index contains dictionary containing user info authorized use app.

i had problem. need use latest version of code oauth2.py, in github. in particular, see changelist:

https://github.com/instagram/python-instagram/commit/d46e0eb96dcf5a3aad687da4081b91441b3392e5

in particular, old , new line in oauth2.py:

-        if include_signed_request: +        if include_signed_request , self.api.client_secret not none: 

everything works after change.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -