Тема: [Вопрос] Вопрос-ответ [Помощь]
Показать сообщение отдельно
uZZer
09.01.2014
 
 
Аватар для uZZer
Мимо проходил, заглянул)
О пользователе
 
Сообщений: 5
ВкоптоКарма: 0


[#4121]
По умолчанию

Цитата:
Сообщение от Вэлл Посмотреть сообщение
uZZer, использовать левые проги для этого или писать php скрипт, который будет по крону постить инфу
Текст скрипта есть, вот:
Code
Код:
<?php
$access_token = 'твой токен';
date_default_timezone_set ('Asia/Yerevan');
$time = date("H:i [d.m]");
$RequestsGet = curl('https://api.vk.com/method/friends.getRequests?need_count=1&access_token=' .$access_token);
$json1 = json_decode($RequestsGet,1);
$countR = $json1['response']['0'];
$messageGet = curl('https://api.vk.com/method/messages.get?access_token='.$access_token);
$json = json_decode($messageGet,1);
$countM = $json['response']['0'];
$load = rand(10,90);
$weater = file_get_contents("http://informer.gismeteo.ru/xml/26063_1.xml");
$xml = xml_parser_create();
$indexes = array();
$values = array();
xml_parse_into_struct($xml,$weater, $values, $indexes);
xml_parser_free($xml);
$wiz = $values[38][attributes][MAX];
$hours = ceil((mktime(0,0,0, 1, 1, 2014) - time())/3600);
$status = '| Текущее время '.$time.' | Всего сообщений: '.$countM.' | До нового года '.$hours.' часов | Заявок в друзья: '.$countR.' | В Санкт-Петербурге '.$wiz.'°с |';
$statusSet = curl('https://api.vk.com/method/status.set?text='.urlencode($status).'&access_token='.$access_token);
$jsonS = json_decode($statusSet,1);

if ($jsonS['response']=='1'){
addlog('OK');
}
else{
addlog('ERROR: '.$jsonS['error']['error_msg']);
}

function addlog($logtext){
$fp = fopen( './statusLog.txt', 'a' );
fwrite( $fp, '['.date( 'd.m.Y H:i:s', time() ).'] '.$logtext.PHP_EOL);
}

function curl( $url ){
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
$response = curl_exec( $ch );
curl_close( $ch );
return $response;
}
?>

Что с этим делать далее и куда девать?
Оффлайн
 
Ответить с цитированием