Curl функции для работы с https

Written by

in

Анализирую попадания блуждающих по инету на мой блог понял чего народу не хватает.
Попытаюсь поделиться наработками.

написал 2 функции для себя одна отправляет ГЕТ запрос вторая ПОСТ

function send_get($get_url,$coo,$refer)
{
// $get_url — Урла которую надо гетнуть ,$coo- строка куков,$refer — от куда идём
$ch = curl_init();
// curl_setopt($ch, CURLOPT_PROXY, «http://192.168.100.6:8080»);
curl_setopt($ch, CURLOPT_URL, $get_url);
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_REFERER, $refer );
curl_setopt($ch, CURLOPT_COOKIE,$coo);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, «Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)»);
curl_setopt($ch, CURLOPT_VERBOSE,1);
return $data = curl_exec($ch);
$type=curl_multi_getcontent($ch);
}

Вторая для POST
function send_post($post_url,$post_data,$coo,$refer)
{
// Всё как и выше только Рост урла и пост дата — которую надо слать
$ch = curl_init();
//curl_setopt($ch, CURLOPT_PROXY, «http://192.168.100.6:8080»);
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_REFERER, $refer );
curl_setopt($ch, CURLOPT_COOKIE,$coo);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, «Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)»);
curl_setopt($ch, CURLOPT_VERBOSE,1);
echo $data = curl_exec($ch);
$type=curl_multi_getcontent($ch);
$coo=filter3($type);
curl_close($ch);
return $type;
}

Comments

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *