Skip to content

Instantly share code, notes, and snippets.

@krll-k
Created September 10, 2012 11:46
Show Gist options
  • Save krll-k/3690471 to your computer and use it in GitHub Desktop.
Save krll-k/3690471 to your computer and use it in GitHub Desktop.
refresh friend list online by time
<?
$host='mysql.hostinger.ru';
$user='u373280085_spy';
$pass='5z9vat8maH';
$bd_name='u373280085_spy';
mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($bd_name) or die(mysql_error());
require 'vkapi.class.php';
$api_id = 2866909;
$secret_key = 'LsFvCs67tFLpoOGZxS5k';
$VK = new vkapi($api_id, $secret_key);
$access_get->user_id = 99598135;
$friends = $VK->api('friends.get', array('uid'=>$access_get->user_id));
$resp = $VK->api('users.get', array('uids'=>implode(',',$friends['response']), 'fields'=>'uid,online'));
for ($i = 0; $i <= count($resp['response']); $i++) {
$table_name=$resp['response'][$i]['uid'].'_';
$uid=$resp['response'][$i]['uid'];
$online=$resp['response'][$i]['online'];
$tima=time();
mysql_query("CREATE TABLE `". $table_name ."` (`id` int not null, PRIMARY KEY(id), AUTO_INCREMENT(id), `online` int not null, `timestamp` int not null)") or die(mysql_error());
echo $resp['response'][$i]['first_name'].' '.$resp['response'][$i]['last_name'].' - '.$resp['response'][$i]['online'].'<br>';
}
Print "Your table has been created";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment