3月1 - 2日我的python函数中发生了一些事情,它发布到了VK组。 我是通过以下方式做到的:
session = vk.Session(access_token=page.access_token)
api = vk.API(session)
post_response = api.wall.post(message=message, owner_id='-' + page.page_id)
但是现在这个最后的post()命令返回以下内容:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/admin/python/lib/python2.7/site-packages/vk/api.py", line 173, in __call__
return self._api._session.make_request(self)
File "/home/admin/python/lib/python2.7/site-packages/vk/api.py", line 67, in make_request
response = self.send_api_request(method_request, captcha_response=captcha_response)
File "/home/admin/python/lib/python2.7/site-packages/vk/api.py", line 115, in send_api_request
response = self.requests_session.post(url, method_args, timeout=timeout)
File "/home/admin/python/lib/python2.7/site-packages/requests/sessions.py", line 518, in post
"""
File "/home/admin/python/lib/python2.7/site-packages/vk/utils.py", line 78, in request
response = super(LoggingSession, self).request(method, url, **kwargs)
File "/home/admin/python/lib/python2.7/site-packages/requests/sessions.py", line 475, in request
the server's TLS certificate, or a string, in which case it must be a path
File "/home/admin/python/lib/python2.7/site-packages/requests/sessions.py", line 585, in send
"""
File "/home/admin/python/lib/python2.7/site-packages/requests/adapters.py", line 477, in send
r,
SSLError: [Errno 2] No such file or directory
如果我想获得上传服务器,我会得到完全相同的错误:
>>> upload_server = api.photos.getWallUploadServer(group_id=page.page_id)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/home/admin/python/lib/python2.7/site-packages/vk/api.py", line 173, in __call__
return self._api._session.make_request(self)
File "/home/admin/python/lib/python2.7/site-packages/vk/api.py", line 67, in make_request
response = self.send_api_request(method_request, captcha_response=captcha_response)
File "/home/admin/python/lib/python2.7/site-packages/vk/api.py", line 115, in send_api_request
response = self.requests_session.post(url, method_args, timeout=timeout)
File "/home/admin/python/lib/python2.7/site-packages/requests/sessions.py", line 518, in post
"""
File "/home/admin/python/lib/python2.7/site-packages/vk/utils.py", line 78, in request
response = super(LoggingSession, self).request(method, url, **kwargs)
File "/home/admin/python/lib/python2.7/site-packages/requests/sessions.py", line 475, in request
the server's TLS certificate, or a string, in which case it must be a path
File "/home/admin/python/lib/python2.7/site-packages/requests/sessions.py", line 585, in send
"""
File "/home/admin/python/lib/python2.7/site-packages/requests/adapters.py", line 477, in send
r,
SSLError: [Errno 2] No such file or directory
我正在使用最新版本的vk包(https://pypi.python.org/pypi/vk,但现在已经1岁了。)
我发现的VK API中唯一的变化 - https://vk.com/dev/version_update - 说现在我必须指定API版本;但当我将api = vk.API(session)
替换为api = vk.API(session, v='5.54')
时,没有任何变化。
也许有人有任何想法如何解决这个问题?谢谢!
答案 0 :(得分:0)
正如@aws_apprentice所写,pip install -U requests[security]
有所帮助。
然后我仍然需要修复API的一些问题:
api = vk.API(session)
替换为api = vk.API(session, v="5.54")
(您可能希望使用https://vk.com/dev/versions
中的最新版本)api.photos.getWallUploadServer
的结果中,现在有一个键album_id
而不是aid
api.photos.saveWallPhoto(...)[0]['id']
现在是int,而不是字符串这些变化对我来说已经足够了。看起来它又有效了!