Http://blog.sina.com.cn/s/blog_51a71c010100gbua.html
(The server is Java, encoding UTF-8, return data encoding UTF-8; Data Exchange Format JSON.
Procedure tloginform. loginbtnclick (Sender: tobject );
VaR
Jo: isuperobject; // JSON Interface
Req: ixmlhttprequest;
URL: widestring; // URL to be accessed
Params: string; // data to be submitted
Begin
// URL to be accessed
URL: = 'HTTP: // localhost/wuliu/servlet/login ';
{Req: = coxmlhttp. Create; // use this name for delphi2010}
// Instantiate ixmlhttprequest
Req: = coxmlhttprequest. Create;
// Call the Open Method
Req. Open ('post', URL, false, emptyparam, emptyparam );
// Set post Parameters
Req. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded ');
// Req. setRequestHeader ('content-length', inttostr (length (sparams )));
// Submit data
Params: = 'account = Hello everyone & Password = good ';
// Send the request
Req. Send (Params );
Showmessage (req. responsetext );
// JO: = So (req. responsetext );
End;
The above is my implementation method. You can submit the required parameters to the server correctly. Note Req. setRequestHeader ('content-type', 'application/X-WWW-form-urlencoded'). This parameter is required for the post parameter data. Params: = 'account = Hello everyone & Password = good'; it is the parameter data to be submitted, type: string. These are ready. Use Req. Send (Params); submit the data to the server; the obtained data is Req. responsetext );
If you have any questions, please contact: sunylat@gmail.com