Advertisement
alpa_s

Untitled

Dec 21st, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. /**
  2. * Метод для получения строки с лендом
  3. * @param string $url
  4. * @return mixed|string $result
  5. */
  6. public static function getUrl($url)
  7. {
  8.  
  9. $page = @file_get_contents($url);
  10.  
  11. if (empty($page)) {
  12. $header[0] = "Cookie: RCPC=ae9c06ab528b1cf06d6309bc1ce6f751; _ym_uid=1477632138319101296; _ym_isad=1";
  13.  
  14. $path_to_runtime = Yii::getAlias('@runtime') . self::COOKIE_FILE;
  15. $curl = curl_init($url);
  16. curl_setopt($curl, CURLOPT_HEADER, true);
  17. curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
  18. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  19. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  20. curl_setopt($curl, CURLOPT_COOKIEJAR, $path_to_runtime);
  21. curl_setopt($curl, CURLOPT_COOKIEFILE, $path_to_runtime);
  22. curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36");
  23. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  24. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  25. curl_setopt($curl, CURLOPT_HEADER, 'Content-Type: application/x-www-form-urlencoded');
  26. $page = curl_exec($curl);
  27. }
  28. return $page;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement