|
5 | 5 | namespace Embed; |
6 | 6 |
|
7 | 7 | class Url { |
| 8 | + public static $resolver = 'Embed\\UrlResolver'; |
8 | 9 | private $result; |
9 | 10 | private $info; |
10 | 11 | private $url; |
@@ -50,32 +51,11 @@ public function __wakeup () { |
50 | 51 | private function resolve () { |
51 | 52 | UrlJsRedirect::resolve($this); |
52 | 53 |
|
53 | | - $connection = curl_init(); |
| 54 | + $resolver = static::$resolver; |
54 | 55 |
|
55 | | - curl_setopt_array($connection, array( |
56 | | - CURLOPT_URL => $this->url, |
57 | | - CURLOPT_RETURNTRANSFER => true, |
58 | | - CURLOPT_FOLLOWLOCATION => true, |
59 | | - CURLOPT_MAXREDIRS => 20, |
60 | | - CURLOPT_CONNECTTIMEOUT => 10, |
61 | | - CURLOPT_TIMEOUT => 10, |
62 | | - CURLOPT_SSL_VERIFYPEER => false, |
63 | | - CURLOPT_SSL_VERIFYHOST => false, |
64 | | - CURLOPT_ENCODING => '', |
65 | | - CURLOPT_AUTOREFERER => true, |
66 | | - CURLOPT_USERAGENT => 'Embed PHP Library' |
67 | | - )); |
68 | | - |
69 | | - $content = curl_exec($connection); |
70 | | - $this->result = curl_getinfo($connection); |
71 | | - |
72 | | - if ($content === false) { |
73 | | - $this->result['error'] = curl_error($connection); |
74 | | - $this->result['error_number'] = curl_errno($connection); |
75 | | - } |
76 | | - |
77 | | - curl_close($connection); |
| 56 | + list($content, $result) = $resolver::resolve($this->url); |
78 | 57 |
|
| 58 | + $this->result = $result; |
79 | 59 | $this->result['starting_url'] = $this->url; |
80 | 60 |
|
81 | 61 | $this->parseUrl($this->result['url']); |
|
0 commit comments