找回密码
 加入
搜索
查看: 3056|回复: 4

[IE类操作] [已解决]求助post请求传入bodyParam参数失败的问题

[复制链接]
发表于 2016-1-4 14:58:37 | 显示全部楼层 |阅读模式
本帖最后由 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)
 楼主| 发表于 2016-1-4 15:47:01 | 显示全部楼层
貌似不是bodyparam的问题,是image参数编码的问题。吐血了。。。
发表于 2016-1-4 17:32:47 | 显示全部楼层
坐等高手
发表于 2016-1-4 17:32:56 | 显示全部楼层
坐等高手
 楼主| 发表于 2016-1-4 17:57:24 | 显示全部楼层
解决了,原来是base64encode换行符搞的鬼。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-12-26 22:32 , Processed in 0.075424 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表