Programming Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C Examples

Bounced Mail
Bz2
Certificates/Keys
Charset
CSV
DKIM / DomainKey
Diffie-Hellman
DSA
Email Object
Encryption
FileAccess
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
MIME
NTLM
POP3
RSA
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
Zip
Amazon S3

 

 

 

 

 

 

 

 

HTTP POST x-www-form-urlencoded

Demonstrates how to send a simple URL encoded POST (content-type = x-www-form-urlencoded). Form params are passed in the HTTP request body in x-www-form-urlencoded format.

Downloads:

MS Windows Visual C/C++ Libraries
Linux/CentOS C/C++ Libraries
MAC OS X C/C++ Libraries
Solaris C/C++ Libraries
C++ Builder Libraries
#include <C_CkHttp.h>
#include <C_CkHttpRequest.h>
#include <C_CkHttpResponse.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkHttpRequest req;
    HCkHttpResponse resp;

    http = CkHttp_Create();

    //  Any string unlocks the component for the 1st 30-days.
    success = CkHttp_UnlockComponent(http,"Anything for 30-day trial");
    if (success != TRUE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        return;
    }

    req = CkHttpRequest_Create();

    //  Add the request params expected by the server-side:
    CkHttpRequest_AddParam(req,"city","Paris");
    CkHttpRequest_AddParam(req,"country","France");

    //  Send the POST  (This is a real URL that may be tested.)

    resp = CkHttp_PostUrlEncoded(http,"http://www.chilkatsoft.com/httpTest/cityCountry.asp",req);
    if (resp == 0 ) {
        printf("%s\n",CkHttp_lastErrorText(http));
        return;
    }

    CkHttpResponse_Dispose(resp);

    //  The exact HTTP request sent and response received
    //  by the example code above is as follows:

    //  
---- Sending ----
POST /httpTest/cityCountry.asp HTTP/1.1
Host: www.chilkatsoft.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 25

city=Paris&country=France
---- Received ----
HTTP/1.1 200 OK
Date: Wed, 09 Dec 2009 16:16:00 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
Content-Length: 156
Content-Type: text/html
Set-Cookie: ASPSESSIONIDQCDTSSAC=MHJCNFMDENFOKGINOFEDILCM; path=/
Cache-control: private


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>

France<br />Paris<br />

</body>
</html>


    CkHttp_Dispose(http);
    CkHttpRequest_Dispose(req);

    }

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.