HTTP protocol-php using Curl_init post to submit JSON external server error

Source: Internet
Author: User
Keywords HTTP protocol json PHP Curl
HTTP protocol 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); All data is sent using the HTTP protocol post operation
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. "
"; Error number output 0
echo "Error:". Curl_error ($ch);
echo $result. "
"; Execution information Error
Curl_close ($ch); [/code]

JSON string: {"Ccode": "1234ew4", "ddate": "2015-12-16", "Ccuscode": "0100001", "Cinvcode": "100101", "iquantity": "1", " Address ":" Test Location "," Cmemo ":" None "," Cmaker ":" Demo "," Cverifer ":" Demo "," Dpredate ":" 2015-12-17 "," Imoney ":" 1 "}
Where Ccode is required to change, the same insertion does not go in.

Error message
[Img=http://img.bbs.csdn.net/upload/201512/18/1450420302_248471.jpg] [/IMG]

Because you are inserting data into a third party, you cannot change the form of the upload, only the JSON format can be uploaded.
Alternatively, if you enter http://61.153.225.106:5678/Service.asmx/tests in the Web page and then enter the string, you can return the string. After the end of the thought is not the transmission protocol problem, but I preach is really content-type for JSON data. For God's advice, only 12 points are sent.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.