Есть php:
<?php
define('__GROOT__', __DIR__);
date_default_timezone_set('Europe/Moscow');
/*$h = date('G');
if ($h > 2 && $h < 7) {
echo 'Ещё не время!';
exit;
}*/
#sleep(rand(1, 200));
include('vendor/autoload.php');
include('Classes/VkAuth.php');
require('Classes/Antigate.php');
require('Classes/VK.php');
require('Classes/Reader.php');
require('Classes/Attachments.php');
require('Classes/Posted.php');
require('Classes/Filter.php');
$config_name = 'configs/config.php';
if (!empty($argv) && array_key_exists('1', $argv) && mb_strlen($argv[1]) > 2) {
$config_name = $argv[1];
}
if (array_key_exists('config', $_GET)) {
$config_name = $_GET['config'];
}
$config = include($config_name);
$need_auth = false;
if ($config['antigate'] != "") {
$antigate = new Antigate($config['antigate']);
}
if (file_exists(__DIR__.'/tokens/'.$config['vk_login'].".txt")) {
$user_data['access_token'] = trim(file_get_contents(__DIR__.'/tokens/'.$config['vk_login'].".txt"));
$vk = new VK\VK($config['client_id'], $config['client_secret'], $user_data['access_token']);
$vk->setApiVersion('5.37');
if ($config['antigate'] != "") {
$vk->setAntigate($antigate);
}
$res = $vk->api('users.get', array());
if (!array_key_exists('response', $res)) {
$need_auth = true;
} else {
if(!array_key_exists('0', $res['response'])) {
$need_auth = true;
}
}
} else {
$need_auth = true;
}
if ($need_auth == true) {
$vk_auth = new VkAuth($antigate);
$user_data = $vk_auth->auth($config['vk_login'], $config['vk_pass'], $config['client_id'], $config['client_secret'], $config['for_check']);
file_put_contents(__DIR__.'/tokens/'.$config['vk_login'].".txt", $user_data['access_token']);
$vk = new VK\VK($config['client_id'], $config['client_secret'], $user_data['access_token']);
$vk->setApiVersion('5.37');
if ($config['antigate'] != "") {
$vk->setAntigate($antigate);
}
}
$epn = new \EpnBzLib\EpnBz($config['epnlogin'], $config['epnpassword']);
$filter = new Filter();
$reader = new Reader($vk, $config);
$groups_ids = $reader->getGroupsIds($config['links_file']);
$ok = false;
$max = 0;
$posted = new Posted();
while (!$ok) {
if ($max > 10) {
echo 'Ошибка выполнения!';
exit;
}
$rand_id = $groups_ids[array_rand($groups_ids)];
$data = array(
"owner_id" => $rand_id*-1,
"count" => 10
);
$wall_data = $vk->api('wall.get', $data);
#var_dump($wall_data);
for ($i = 0; $i < count($wall_data['response']['items']); ++$i) {
$fail = false;
$posted_ids = $reader->getPostedIds($config['posted_ids_file']);
$post = $wall_data['response']['items'][$i]['owner_id'].'_'.$wall_data['response']['items'][$i]['id'];//пост из источника
if (!$reader->isPosted($posted_ids, $post)) {
$post_data = $wall_data['response']['items'][$i];
if ($config['adblock']) {
if (!$filter->check($post_data['text'])) {
echo 'Не прошло проверку рекламы!'.PHP_EOL;
continue;
}
}
$matches = array();
$preg = preg_match('#(?<!])http://[^s[<]+#i', $post_data['text'], $matches);
//var_dump($matches);
if (array_key_exists(0, $matches)) {
$ali_url = '';
for ($i = 0; $i < 5; $i++) {
sleep(1);
$ali_url = $epn->getUrl(trim($matches[0]));
if ($ali_url !== false) {
break;
}
}
var_dump($ali_url);
for ($i = 0; $i < 5; $i++) {
$ali_url = $epn->short($ali_url);
if ($ali_url !== false) {
$fail = false;
break;
} else if ($i == 4) {
$posted->add($config['posted_ids_file'], $post);
echo 'Всё очень плохо';
$fail = true;
break;
}
}
if ($fail) {
continue;
}
$post_data['text'] = str_replace($matches[0], $ali_url, $post_data['']);
} else {
echo 'Нет ссылок';
continue;
}
$ok = true;
break;
} else {
echo 'Уже было запощено!'.PHP_EOL;
}
}
$max++;
}
$attachments = '';
if (array_key_exists('attachments', $post_data)) {
$at = new Attachments($vk);
$attachments = $at->convert($post_data['attachments'], $config['public_id']);
}
$post_text = $post_data['text'].$config['add_text'];
#$post_text = $post_data['text']."\n\n".$reader->getPostStrs($config['post_text']);
$new_post = array(
"owner_id" => $config['public_id']*-1,
"from_group" => "1",
"message" => $post_text,
"attachments" => $attachments
);
$result = $vk->api('wall.post', $new_post);
if ($result['response']['post_id'] < 1) {
echo 'Пост не добавлен!'.PHP_EOL;
exit;
} else {
$posted->add($config['posted_ids_file'], $post);
}
выходит ошибка в нем на строчке 91
[Sat Jun 30 23:25:07.055467 2018] [:error] [pid 13613] [client 92.127.158.61:38940] PHP Notice: Undefined index: response in /var/www/dc776/data/www/mou.site/1/grab.php on line 91
Строчка 91 это :
for ($i = 0; $i < count($wall_data['response']['items']); ++$i) {