Advertisement
NFL

VK cURL demo

NFL
Feb 27th, 2013
1,363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. <?php
  2. /*
  3. ИЗМЕНИТЬ ДАННЫЕ ДОСТУПА
  4. */
  5.  $mail = 'ЛОГИН';
  6.  $pass = 'ПАРОЛЬ';
  7.  
  8.  $otvet=connect("http://login.vk.com/?act=login&email=$mail&pass=$pass");
  9.  If(!preg_match("/hash=([a-z0-9]{1,32})/",$otvet,$hash)){
  10.  die("Login incorrect");
  11.  }
  12.  $otvet=connect("http://vk.com/login.php?act=slogin&hash=".$hash[1]);
  13.  preg_match("/remixsid=(.*?);/",$otvet,$sid);
  14.  $cookie = "remixchk=5; remixsid=$sid[1]";
  15.   $ch = curl_init();  
  16. curl_setopt($ch, CURLOPT_URL, 'http://vk.com/video5635006_163692379');  //получаем тестовое видео
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  19. curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  20. $result = curl_exec($ch);
  21. $data = iconv('cp1251', 'utf-8', $result);
  22. /**/
  23. preg_match_all('/\\"thumb\\\":\\\"(.*?)\\\",/',$data,$match); //вытягиваем превью
  24. $img = $match[1][0];
  25. var_dump($img); //получаем картинку
  26. curl_close($ch);
  27.  
  28.  
  29.  
  30.  function connect($link,$cookie=null,$post=null){
  31.  $ch = curl_init();
  32.  curl_setopt($ch, CURLOPT_URL,$link);
  33.  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  34.  curl_setopt($ch, CURLOPT_TIMEOUT, 0);
  35.  curl_setopt($ch, CURLOPT_HEADER, 1);
  36.  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  37.  if($cookie !== null)
  38.  curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  39.  if($post !== null)
  40.  {
  41.  curl_setopt($ch, CURLOPT_POST, 1);
  42.  curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  43.  }
  44.  $otvet = curl_exec($ch);
  45.  curl_close($ch);
  46.  return $otvet;
  47.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement