public function request($query,$param,$type="POST",$headers=false,$custom_header=[],$follow_location=true) {
$url=$this->url.$query;
if ($this->debug==true){echo "URL:$url\n";};
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_VERBOSE, $this->debug);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $follow_location);
if ($headers==true){
curl_setopt($ch, CURLOPT_HEADER, 1);
};
if ($type=="POST"){
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
if ($this->debug==true){
echo "---------------- POST -------------\n";
var_dump($param);
echo "-----------------------------------\n";
};
};
if (count($custom_header)>0){
curl_setopt($ch, CURLOPT_HTTPHEADER, $custom_header);
if ($this->debug==true){
echo "---------------- HEADER -------------\n";
var_dump($custom_header);
echo "-----------------------------------\n";
};
};
if (count($this->cookies)>0){
$str_cook="";
foreach ($this->cookies as $key=>$value) {
$str_cook=$str_cook.$key."=".$value.";";
};
if ($this->debug==true){
echo "COOKIE:$str_cook\n";
};
curl_setopt($ch, CURLOPT_COOKIE,$str_cook);
};
$res=curl_exec($ch);
if (curl_errno($ch)) {
$error_msg = curl_error($ch);
if ($this->debug==true){
var_dump($res);
var_dump($error_msg);
die();
};
};
if ($this->debug==true){
echo "---------------- РЕЗУЛЬТАТ -------------\n";
var_dump($res);
echo "-------------------------- -------------\n";
};
return $res;
}