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分全部送上