Back to Collection Items
<?php
include("chilkat.php");
// Use "chilkat_9_5_0.php" for versions of Chilkat < 10.0.0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
$http = new CkHttp();
// Use this online tool to generate code from sample JSON: Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "account": "4444333322221111"
// }
$json = new CkJsonObject();
$json->UpdateString('account','4444333322221111');
$http->SetRequestHeader('Content-Type','application/json');
// resp is a CkHttpResponse
$resp = $http->PostJson3('https://domain.com/','application/json',$json);
if ($http->get_LastMethodSuccess() == false) {
print $http->lastErrorText() . "\n";
exit;
}
print $resp->get_StatusCode() . "\n";
print $resp->bodyStr() . "\n";
?>
Curl Command
curl -X POST
-H "Content-Type: application/json"
-d '{
"account" : "4444333322221111"
}'
https://domain.com/
Postman Collection Item JSON
{
"name": "Tokenize (Card Number)",
"event": [
{
"listen": "test",
"script": {
"exec": [
"var jsonData = JSON.parse(responseBody);",
"postman.setEnvironmentVariable(\"token\", jsonData.token);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"name": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"account\" : \"4444333322221111\"\n}"
},
"url": {
"raw": "{{csurl}}",
"host": [
"{{csurl}}"
]
},
"description": "CardSecure API v1 Documentation Coming Soon\n\n**Note:** This is not required, but shows a simple call to the CardSecure API to tokenize a credit card number. It can be used to setup the token variable used in this Postman environment."
},
"response": [
]
}