Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

vk

By: a guest on Dec 15th, 2012  |  syntax: None  |  size: 1.50 KB  |  views: 674  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2. /*
  3. CONFIG
  4. ____________________________________*/
  5. $login = ''; //skuter-2000@mail.ru
  6. $pass = ''; //smoke1337
  7.  
  8. $auth = curl( 'https://oauth.vk.com/token?grant_type=password&cl..'. $login .'&password='. $pass );
  9. $json = json_decode( $auth, true );
  10. $access_token = $json['access_token'];
  11. $days = date( 'z', mktime( 0, 0, 0, 1, 1, 2013 ) - time() );
  12. $endingArray = array('16', 'дня', 'дней');
  13. $number = $days % 100;
  14. if ($number>=11 && $number<=19) {
  15. $ending = $endingArray[2];
  16. } else {
  17. $i = $number % 10;
  18. switch($i) {
  19. case 1:
  20. $res = 'До Нового Года осталось '. $days .' '. $endingArray[0];
  21. break;
  22. case 2:
  23. case 3:
  24. case 4:
  25. $res = 'До Нового Года осталось '. $days .' '. $endingArray[1];
  26. break;
  27. default:
  28. $res = 'До Нового Года осталось '. $days .' '. $endingArray[2];
  29. }
  30. }
  31. $statusSet = curl( 'https://api.vk.com/method/status.set?text='. urlencode( $res ) .'&access_token='. $access_token );
  32. $fp = fopen( 'log.txt', 'a' );
  33. $json = json_decode( $statusSet, true );
  34. if( isset( $json['response'] ) ) {
  35. fwrite( $fp, '['.date( 'd.m.Y H:i:s', time() ).'] Status set'.PHP_EOL );
  36. } else {
  37. fwrite( $fp, '['.date( 'd.m.Y H:i:s', time() ).'] Error'.PHP_EOL );
  38. }
  39.  
  40. function curl( $url ) {
  41. $ch = curl_init( $url );
  42. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  43. curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  44. curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  45.  
  46. $response = curl_exec( $ch );
  47. curl_close( $ch );
  48. return $response;
  49. }
  50. ?>
clone this paste RAW Paste Data