[已解决]求助post请求传入bodyParam参数失败的问题
本帖最后由 kxing 于 2016-1-4 17:57 编辑我按照php的范例转成au3了,结果还是提示参数错误,不知道au3除了send方法发送参数还有其他办法吗,或者说我哪里错了,求大神指点,谢谢。
php code:
<?php
$ch = curl_init();
$url = 'http://apis.baidu.com/idl_baidu/baiduocrpay/idlocrpaid';
$header = array(
'Content-Type:application/x-www-form-urlencoded',
'apikey: 1fb549a4d0d00302c460829f90e9ab60',
);
$data = "fromdevice=pc&clientip=10.10.10.0&detecttype=LocateRecognize&languagetype=CHN_ENG&imagetype=1&image=/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDABMNDxEPDBMREBEWFRMXHTAfHRsbHTsqLSMwRj5KSUU+RENNV29eTVJpU0NEYYRiaXN3fX59S12Jkoh5kW96fXj/2wBDARUWFh0ZHTkfHzl4UERQeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHj/wAARCAAfACEDAREAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAQDBQb/xAAjEAACAgICAgEFAAAAAAAAAAABAgADBBESIRMxBSIyQXGB/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/APawEBAQEBAgy8i8ZTVV3UY6V1eU2XoWDDZB19S646Gz39w9fkKsW1r8Wm2yo1PYis1be0JG9H9QNYCAgc35Cl3yuVuJZl0cB41rZQa32dt2y6OuOiOxo61vsLcVblxaVyXD3hFFjL6La7I/sDWAgICAgICB/9k=";
// 添加apikey到header
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
// 添加参数
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// 执行HTTP请求
curl_setopt($ch , CURLOPT_URL , $url);
$res = curl_exec($ch);
echo $res;
?>
au3 code:
$url="http://apis.baidu.com/idl_baidu/baiduocrpay/idlocrpaid"
$data = "fromdevice=pc&clientip=10.10.10.0&detecttype=LocateRecognize&languagetype=CHN_ENG&imagetype=1&image=/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDABMNDxEPDBMREBEWFRMXHTAfHRsbHTsqLSMwRj5KSUU+RENNV29eTVJpU0NEYYRiaXN3fX59S12Jkoh5kW96fXj/2wBDARUWFh0ZHTkfHzl4UERQeHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHj/wAARCAAfACEDAREAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAAQDBQb/xAAjEAACAgICAgEFAAAAAAAAAAABAgADBBESIRMxBSIyQXGB/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/APawEBAQEBAgy8i8ZTVV3UY6V1eU2XoWDDZB19S646Gz39w9fkKsW1r8Wm2yo1PYis1be0JG9H9QNYCAgc35Cl3yuVuJZl0cB41rZQa32dt2y6OuOiOxo61vsLcVblxaVyXD3hFFjL6La7I/sDWAgICAgICB/9k="
$oIE=ObjCreate("winhttp.winhttprequest.5.1")
$oIE.Open("POST",$url,false)
$oIE.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
$oIE.setRequestHeader("apikey","1fb549a4d0d00302c460829f90e9ab60")
$oIE.Send($data)
$res=$oIE.responseBody
$res=binarytostring($res,1)
msgbox(0,'ok',$res)
貌似不是bodyparam的问题,是image参数编码的问题。吐血了。。。 坐等高手{:face (396):} 坐等高手{:face (396):} 解决了,原来是base64encode换行符搞的鬼。。。
页:
[1]