Conversational bot for Vkontakte PHP

Intro. Lyrics


Somehow one day it occurred to me that it would be nice if everyday tasks such as posting and maintaining account activity in any social network served not a man, a simple conversational bot. Especially in the "botnet" of several hundred accounts to perform the task with one person is impractical and almost impossible. So the idea arose to write a conversational bot means that best I have known. I decided to make a bot in PHP.

the

Database response


To start, as you may have guessed, it was necessary to search databases for answers bot and basic technical job that would help to make it quickly and with a minimum number of crutches (I have no crutches did not work).

A little earlier, I met one interesting project from the company "at nanosemantika" engaged in similar tasks and creates, like commercial bots-supports and so on. This project iii.ru. On the project website you can create a bot and get it flash version to embed on the website. API they had, had to decompile the swf.

the

was encoded?!


The first thing that came to my head when I opened the decompiled code of the SWF file — now where to find the output responses and how to turn in the direction of his ideas. Surprise knew no bounds when I saw that all requests and responses are encrypted with XOR + Base64, and decryption key were in the beginning of the code. Why then kriptovat?

the

Technical question


The main tasks that had to carry my boat to the last message with "Vkontakte", send them to the server, receive the response, send a response to the person who communicates with the bot.

It created the following files:
— index.php (works as a client to update using jquery file upload come message and the subsequent reply)
— autoload.php (actually, the file that receives and responds)
— showmeid.php (the file which creates a new chat ID if the person first communicates with the bot)
— config.php (connect to the database with the clients of the bot)
— classes.php (classes for working with the bot)

the

Installation


1. Import the dump.sql in your database
2. Get long-lived access token to work with VK API with references to a token
3. Rename config.sample.php in config.php after transforming the data to connect to the database
4. Use running index.php

So, please to meet you — Larisa Chernyshova

As well as source on GitHub.

UPD: If the bot does not respond — means is blocked sending a message asking to enter a captcha.

For details and questions welcome to my blog
Article based on information from habrahabr.ru

Комментарии

Популярные сообщения из этого блога

March Habrameeting in Kiev

PostgreSQL load testing using JMeter, Yandex.Tank and Overload

Monitoring PostgreSQL with Zabbix