L
L
Library_Keepeer2020-11-17 20:09:59
Python
Library_Keepeer, 2020-11-17 20:09:59

How to make requests to the VK API Python and how to get the necessary information from json?

I have code

from flask import Flask, request, json
import vk
import numpy as np
import random
token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
confirmation_token = "xxxxxx"
session = vk.Session(access_token=token)
vk_api = vk.API(session, v='5.103')
def msgSend(msg, user_id):
    if msg == 'новый пост' or msg == 'покажи новый пост':
        r = vk_api.wall.get(domain="librarykeeper",offset=1,count=1,filter="owner")
        t = r["response"][0]["items"][0]["id"]
        return t


I need to take one post from my group and get its id if the post is "new post" or "show new post". The msgSend function should simply return the text, which will then be sent in response to the message.
But when I send a message, the bot does not respond to it (the server is connected to the bot and other functions work).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question