php post


<html>
<body>

<?php
function HTTP_Post($URL,$cookie)
{

// parsing the given URL
$URL_Info=parse_url($URL);

var_dump($URL_Info);
// Building referrer

$referrer="111";

// making string from $data
//foreach($data as $key=>$value)
//$values[]="$key=".urlencode($value);
$file="I:/1/1.wav";
$data_string = file_get_contents($file);

//$data_string="kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk";

// Find out which port is needed - if not given use standard (=80)
if(!isset($URL_Info["port"]))
$URL_Info["port"]=80;


$request1="Content-Disposition: form-data;";
$request1.="name=\"test.name\";";
$request1.="opcode=\"transcribe_audio\";";
$request1.="sessionid=\"1\";";
$request1.="tmp_entry_id=\"2222222222222222222\";";
$request1.="filename=\"sssssssss\";";
$request1.="type=\"0\";";
$request1.="time=\"11111111111\";";
$request1.="reqid=\"12345\";";
$request1.="latitude=\"1\";";
$request1.="location=\"1\";";
$request1.="language=\"chinese\";"; // use ThinkIT engine
$request1.="uId=\"1\";";
$request1.="ver=\"1.1-123\";";
$request1.="kId=\"46\";";
$request1.="aId=\"2\";";
$request1.="grammarname=\"city\";";
$request1.="sr=\"11\";\r\n";


$boundary = "----------V2ymHFg03ehbqgZCaKO6jy";
// building POST-request:
$request="POST ".$URL_Info["path"]." HTTP/1.1\r\n";
$request.="Host: ".$URL_Info["host"]."\r\n";
$request.="Referer: $referrer\r\n";
$request.="Content-type: multipart/form-data;boundary=".$boundary."\r\n";


$data="--".$boundary."\r\n";

$data.=$request1;
$data.="\r\n";


$data.=$data_string."\r\n";

$data.="--".$boundary."--\r\n";

$request.="Content-length: ".strlen($data)."\r\n";
$request.="Connection: close\r\n\r\n";
$request.=$data;

echo $request;

$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);
fputs($fp, $request);
$result="";
while(!feof($fp)) {
$result .= fgets($fp, 1024);
}
echo "\r\nsssssss------------".iconv("UTF-8", "GB2312", "$result");
fclose($fp);

return $result;
}


HTTP_Post("http://localhost:8080:/test/up","1");
?>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值