I can't use the Python library that works with the ok.ru API https://github.com/alternativshik/python-odnoklassniki

The manual on the git page states:

import odnoklassniki ok = odnoklassniki.Odnoklassniki(client_key, client_secret, access_token) print ok.group.getInfo('uids'='your_group_id', 'fields'='members_count') 

By analogy, I perform with my data, with the only difference that I execute on 3 versions of python, I modify print function. I get the error:

 Traceback (most recent call last): File "OK API.py", line 31, in <module> x = ok.friends.get(fid='571031948142') File "/usr/local/lib/python3.5/dist-packages/odnoklassniki/api.py", line 100, in __call__ return self._get(self._method, **kwargs) File "/usr/local/lib/python3.5/dist-packages/odnoklassniki/api.py", line 67, in _get status, response = self._request(method, **kwargs) File "/usr/local/lib/python3.5/dist-packages/odnoklassniki/api.py", line 106, in _request for key, value in kwargs.iteritems(): AttributeError: 'dict' object has no attribute 'iteritems' 

    1 answer 1

    api written for python 2 . The error occurs because dict for python 3 does not have the iteritems method, instead it uses the items method.

    To use api in python 3 have to fix it, either manually or with the help of the 2to3 utility.

    For example, like this:

     2to3 -w python-odnoklassniki 
    • That's where the dog is buried. And I already soldered the helicopter: a = session_key b = secretsession_key c = secret_key d = app_key e = App_ID def send(): y = [a, b, c, d, e] random.shuffle(y) print(y) aa = str(y[0]) bb = str(y[1]) cc = str(y[2]) ok = odnoklassniki.Odnoklassniki(aa, bb, cc) x = ok.friends.get(fid='514404667374') print(x) return ok while x == 1: time.sleep(0.05) try: rr = send() break except AttributeError: print('*') pass Which is a random substitution of all known ones. Tin. Thank you - MIKS
    • thank. it is necessary so: "python C:\Users\alexw\AppData\Local\Programs\Python\Python36-32\Tools\scripts\2to3.py -w C:\Users\alexw\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\odnoklassniki\api.py" - Alexandr Volodichev