<?
///andrey69rus
function curl($url)
{
$ch = curl_init( $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.1; WOW64) Presto/2.12.388 Version/12.14');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
#########################################
$token = 'мойтокен'; // токен вк api
$steam_id = 'мой стим id'; /// steam id
#########################################
$result = curl("http://steamcommunity.com/id/$steam_id/");
preg_match('$<div class="profile_in_game_header">(.*?)</div>$si',$result ,$profile_in_game);
if ($profile_in_game[1] == 'Currently In-Game')
{
preg_match('$<div class="profile_in_game_name">(.*?)</div>$si',$result ,$game_name);
$game_time == '';
$result = curl("http://steamcommunity.com/id/$steam_id/games/");
$result = preg_replace('|<!DOCTYP(.*?)"name":"'.$game_name[1].'","last_played":(.*?),"hours":"|is', '',$result);
$result = preg_replace('|","availStatLinks":(.*?)</html>|is', ' ч. всего)',$result);
$game_time = str_replace('","hours_forever":"',' ч. за последние две недели ',$result);
$text .= 'Сейчас я в игре '.$game_name[1] .' ('.$game_time;
};
if ($profile_in_game[1] == 'In non-Steam game')
{
preg_match('$<div class="profile_in_game_name">(.*?)</div>$si',$result ,$game_name);
$text .= 'Сейчас я в игре '.$game_name[1];
};
#################### статус через vk api
echo $text.'<br/>';
$sRequest = "https://api.vk.com/method/status.set?text=".urlencode($text)."&access_token=".$token;
$statusSet = curl($sRequest);
$result = json_decode($statusSet,1);
if ($result['response'] == '1'){
echo 'Test';
}else{
echo 'ERROR: '.$result['error']['error_msg'];
}
?>