function CurlGet link postArr ssl true timeout 30 userAgent PSDO_CURL_

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function CurlGet($link, $postArr = '', $ssl = true, $timeout = 30, $userAgent = PSDO_CURL_UA) {
if ($curl = curl_init()) {
curl_setopt($curl, CURLOPT_URL, $link);
if ($postArr != '') {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postArr);
}
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $ssl);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, $ssl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($curl, CURLOPT_USERAGENT, $userAgent);
$rawResponse = curl_exec($curl);
if(curl_errno($curl)) {
RedirectError('1002', curl_errno($curl));
}
curl_close($curl);
return $rawResponse;
} else RedirectError('1002'); // curl init error
RedirectError('1002', '0000');
}