Http protocol-PHP uses curl_initpost to submit json external server error

Source: Internet
Author: User
[Codephp] $ serviceURL & #39; 61.153.225.106: 5678Service. asmxtests & #39; $ chcurl_init ($ serviceURL); curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST, & quot; POST & quot;); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ($ ch, 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 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 code 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 address", "cmemo": "None", "cmaker": "demo", "cverifer": "demo ", "dpredate": "2015-12-17", "imoney": "1 "}
The ccode needs to be changed, and the same insert is not included.

Error message
[Img = Beijing

Because data is inserted to a third party, the upload format cannot be changed. only json format can be uploaded.
In addition, if you enter http: // 61.153.225.106: 5678/Service. asmx/tests in the webpage, then you can input a string to return a string. After the transfer protocol is complete, I want to see if it is a problem. However, I actually transmit data whose content-type is json. Please kindly advise, only 12 points for all

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.