http协议-PHP使用curl_init post 提交json 外部服务器报错

WBOY
Release: 2016-06-02 11:29:05
Original
1180 people have browsed it

http协议jsonphpcurl

[code=php]$serviceURL = 'http://61.153.225.106:5678/Service.asmx/tests';
$ch = curl_init ( $serviceURL );
curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $strjson ); //全部数据使用HTTP协议的POST操作来发送
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt ( $ch, CURLOPT_HTTPHEADER, array (
'Content-Type: application/json; charset=utf-8;',
'Content-Length: ' . strlen ( $strjson )
) );

curl_setopt($ch,CURLOPT_POST,1);
$result = curl_exec ( $ch );
$errorNo = curl_errno ( $ch );
echo $errorNo."
"; //错误号 输出0
echo "error:".curl_error($ch);
echo $result."
"; //执行信息 报错
curl_close ( $ch );[/code]

json字符串:{"ccode":"1234ew4" , "ddate":"2015-12-16", "ccuscode":"0100001", "cinvcode":"100101", "iquantity":"1", "address":"测试地址", "cmemo":"无", "cmaker":"demo", "cverifer":"demo", "dpredate":"2015-12-17", "imoney":"1"}
其中ccode是需要变化的,同一个插入不进去。

报错信息
[img=http://img.bbs.csdn.net/upload/201512/18/1450420302_248471.jpg][/img]

由于是往第三方插入数据,所以没法改变上传的形式 ,只能上传json格式。
另外如果网页中输入 http://61.153.225.106:5678/Service.asmx/tests 然后再输入字符串是可以返回字符串的。完了以后就想是不是传送协议问题,但是我传的又确实是 content-type 为json的数据 。求大神指教,只有12分全部送上

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template