Answer the question
In order to leave comments, you need to log in
Accessing conversations via VkApi on behalf of the community - how to implement?
import vk_api
import requests
import json
import vk
token = 'токен'
confaid = 2000000001
session = vk_api.VkApi(token=token)
def getlastmsg(confa, token):
payload = {'access_token':token, 'peer_id':confa, 'count':1}
r = requests.get('https://api.vk.com/method/messages.getHistory?v=5.52', params = payload)
txt = r.text
data = json.loads(txt)
print(r.url)
return data['response']['items'][0]['body']
def cmdpart(stroka, number):
stroka0 = stroka.split()
try:
return stroka0[number]
except IndexError:
return 'Ошибка, скорее всего, недостаточно аргументов'
print(getlastmsg(confaid, token))
{"error":{"error_code":15,"error_msg":"Access denied","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"messages.getHistory"},{"key":"v","value":"5.52"},{"key":"peer_id","value":"2000000001"},{"key":"count","value":"1"}]}}
Answer the question
In order to leave comments, you need to log in
messages.getHistory doesn't work on behalf of the community in conversations
using the Bots LongPoll API or Callback API
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question