function getLongPoolHistory()
{
global $connectLong;
$param_for_long = array(
'ts' => $connectLong['ts'],
'pts' => $connectLong['pts'],
'preview_length' => 0,
'access_token' => 'token',
'v' => '5.103'
);
$link = 'https://api.vk.com/method/messages.getLongPollHistory/';
$data = http_build_query( $param_for_long );
global $user_agent;
global $custom_request;
$ch = curl_init( $link );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $custom_request );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
$result = curl_exec( $ch );
curl_close( $ch );
return json_decode( $result );
}
function sendMessage()
{
global $user_agent;
global $custom_request;
global $param_for_message;
$link = 'https://api.vk.com/method/messages.send/';
$data = http_build_query( $param_for_message );
$ch = curl_init( $link );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HEADER, 0 );
curl_setopt( $ch, CURLOPT_USERAGENT, $user_agent );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $custom_request );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
$result = curl_exec( $ch );
curl_close( $ch );
return $result;
}
for ($i=0; $i < 4; $i++)
{
sendMessage();
sleep(13);
}