Murove1

vkstatus weather

Jun 3rd, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. <?php
  2. $login = '[email protected]'; //loginvk
  3. $pass = 'password'; //passvk
  4. $auth = curl( 'https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username='. $login .'&password='. $pass ); //authorization
  5. $json = json_decode( $auth, true );
  6. $access_token = $json['access_token'];
  7.  
  8. preg_match('/<td class="weather__temp"><span>(.*?)<\/span><\/td>/',file_get_contents('http://m.gismeteo.ua/weather/4951/'), $ter);
  9. $ter =$ter[1];//pars weather gismeteo.ua
  10.  
  11.  
  12. $statusSet = curl( 'https://api.vk.com/method/status.set?text='.  urlencode( '⛅Погода:'.$ter ) .'&access_token='. $access_token );//status add
  13. function curl( $url ) {
  14.         $ch = curl_init( $url );
  15.         curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  16.         curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
  17.         curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
  18.         $response = curl_exec( $ch );
  19.         curl_close( $ch );
  20.         return $response;
  21. }
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment