нет времени объяснять.. просто кидаю свой код(ajax + php):
notif.php
Код: Выделить всё
<?phpheader("Content-Type: text/html; charset=utf-8"); require 'init.php'; mysql_connect($db_host,$db_user,$db_pass);mysql_select_db($db_name); $res = mysql_query('SELECT `uid` FROM `users`');$max = floor(mysql_num_rows($res)/100)+1;?><!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>Уведомления</title> <script type="text/javascript" src="jquery.min.js"></script> <style> #mess { width:400px; height:200px; } #log { background:black; color:white; padding:30px; } </style> <script type="text/javascript"> function send(text,counter,max) { $.ajax({ url: 'send.php', type: 'POST', data: {'text':text,'offset':counter*100,'login':$('#login').val(),'password':$('#password').val()}, success: function(data) { $('#log').append(data+'</br>'); if(counter < max-1) send(text,counter+1,max); } }); } </script></head><body><h1>ОТПРАВКА УВЕДОМЛЕНИЙ!</h1><input type="text" id="login"><input type="text" id="password"><input type='textarea' id="mess"><a href="#" onclick="send($('#mess').val(),0,<?php echo $max; ?>);"><h3>ОТПРАВИТЬ!</h3></a></br></br></br></br><h4>ЛОГ...</h4><div id="log"></div></body></html>
send.php
Код: Выделить всё
<?phpheader("Content-Type: text/html; charset=utf-8"); $log = $_POST['login'];$pass = $_POST['password']; $log = addslashes($log);$log = htmlspecialchars($log);$log = mysql_escape_string($log); $pass = addslashes($pass);$pass = htmlspecialchars($pass);$pass = mysql_escape_string($pass); if($log != 'xxx' || $pass != 'xxx') exit('не туда попал'); require ("vkapi.class.php"); require 'init.php'; if(isset($_POST['offset']) && $_POST['offset'] != '') $offset = $_POST['offset']; else exit(' не сработал скрипт...(');if(isset($_POST['text']) && $_POST['text'] != '' ) $text = $_POST['text']; else exit('Введи сообщение'); mysql_connect($db_host,$db_user,$db_pass);mysql_select_db($db_name); $ids = "";$count = 0; $res = mysql_query('SELECT `uid` FROM `users` LIMIT '.$offset.',100');while($row = mysql_fetch_array($res)) { if($count !== 99) $ids .= $row['uid'].','; else $ids .= $row['uid']; $count++;} $VK = new vkapi($app_id, $app_key);$res = $VK->api('secure.sendNotification', array('uids' => $ids, 'message' => $text)); if($res['response'] != "") exit('В позиции от '.$offset.' к '.($offset+100).' отправлено им: '.$res['response']);else exit('В позиции от '.$offset.' к '.($offset+100).' не отправлено никому!'); ?>
(возможно не оптимизирован, но все-же работает.. над этим я не парился
)