function curl($url, $post) { $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.0.4) Gecko/2008102920 AdCentriaIM/1.7 Firefox/3.6"); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POST, 1); $result = curl_exec($ch); curl_close($ch); return $result; };
$result = curl("http://site.ru/post.php", "text=текст");
$result = curl("http://site.ru/post.php", "text=%d1%82%d0%b5%d0%ba%d1%81%d1%82");
$result = curl("http://site.ru/post.php", "text=".urlencode("текст"));
$res = iconv("utf-8", "windows-1251", curl("http://site.ru/post.php", "text=".urlencode(iconv("windows-1251", "utf-8",$text))));