MCPcopy Create free account
hub / github.com/Rello/analytics / fetchUrlContent

Method fetchUrlContent

lib/Datasource/Regex.php:127–150  ·  view source on GitHub ↗

* Fetches the content of a URL using cURL. * @param string $url * @return array [string $content, int $httpCode] */

(string $url)

Source from the content-addressed store, hash-verified

125 * @return array [string $content, int $httpCode]
126 */
127 private function fetchUrlContent(string $url): array
128 {
129 $ch = curl_init();
130 if ($ch === false) {
131 return ['', 0];
132 }
133
134 curl_setopt_array($ch, [
135 CURLOPT_SSL_VERIFYPEER => true,
136 CURLOPT_SSL_VERIFYHOST => 2,
137 CURLOPT_HEADER => false,
138 CURLOPT_FOLLOWLOCATION => false,
139 CURLOPT_URL => $url,
140 CURLOPT_REFERER => $url,
141 CURLOPT_RETURNTRANSFER => true,
142 CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'
143 ]);
144
145 $result = curl_exec($ch);
146 $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
147 curl_close($ch);
148
149 return [$result !== false ? $result : '', $httpCode];
150 }
151}

Callers 1

readDataMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected