$val) { $fdata .= "$key=" . urlencode($val) . "&"; } return $fdata; } function curl_get($url, $data) { $ch = curl_init(); // create cURL handle (ch) if (!$ch) { die("Couldn't initialize a cURL handle"); } // set some cURL options $ret = curl_setopt($ch, CURLOPT_URL, $url); $ret = curl_setopt($ch, CURLOPT_POST, true); $ret = curl_setopt($ch, CURLOPT_POSTFIELDS, $data); $ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //$ret = curl_setopt($ch, CURLOPT_HEADER,0); //$ret = curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); $ret = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $ret = curl_setopt($ch, CURLOPT_TIMEOUT, 30); // execute $ret = curl_exec($ch); if (empty($ret)) { // some kind of an error happened die(curl_error($ch)); curl_close($ch); // close cURL handler } else { $info = curl_getinfo($ch); curl_close($ch); // close cURL handler if (empty($info['http_code'])) { die("No HTTP code was returned"); } else { // load the HTTP codes // $http_codes = parse_ini_file("path/to/the/ini/file/I/pasted/above"); // // // echo results // echo "The server responded:
"; // echo $info['http_code'] . " " . $http_codes[$info['http_code']]; } } return $ret; } function setdata($data) { foreach ($data as $key => $value) { $pos = strpos($key, "pdf"); if (!is_bool($pos)) { $re .= "$key=$value&"; } } return $re; } function setdata2($data) { foreach ($data as $key => $value) { $re .= "$key=$value&"; } return $re; }