February 6, 2025

API dr.cash

JavaScript

<form class="orderForm">
    <input type="text" name="name" placeholder="name" />
    <input type="text" name="phone" placeholder="phone" />
    <input type="text" name="surname" placeholder="surname" />
    <input type="text" name="email" placeholder="email" />
    <input type="text" name="country" placeholder="country" />
    <input type="text" name="city" placeholder="city" />
    <input type="text" name="postcode" placeholder="postcode" />
    <input type="text" name="address" placeholder="address" />
    <input type="hidden" name="ip" value="" />
    <input type="submit" value="Submit">
</form>
<script src="https://snippet.infothroat.com/dist/api/lead-1.1.0.min.js"></script>
<script>
  drlead.init({
    params: {
      token: "your_api_token", // required
      stream_code: "your_stream_code", // required
      thanks_page: "./thanks.html"
    },
    subs: {
      sub1: drlead.formInputGet("sub1") || drlead.queryGet("sub1"),
      sub2: drlead.formInputGet("sub2") || drlead.queryGet("sub2"),
      sub3: drlead.formInputGet("sub3") || drlead.queryGet("sub3"),
      sub4: drlead.formInputGet("sub4") || drlead.queryGet("sub4"),
      sub5: drlead.formInputGet("sub5") || drlead.queryGet("sub5"),
    },
    callback: function (error, response) {
      // On request done
    },
    before: function() {
      // before request done
    }
  });
</script>

PHP

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form class="orderForm" method="post" action="/">
    <input type="text" name="name" placeholder="name" />
    <input type="text" name="phone" placeholder="phone" />
    <input type="text" name="surname" placeholder="surname" />
    <input type="text" name="email" placeholder="email" />
    <input type="text" name="country" placeholder="country" />
    <input type="text" name="city" placeholder="city" />
    <input type="text" name="postcode" placeholder="postcode" />
    <input type="text" name="address" placeholder="address" />
    <input type="hidden" name="ip" value="" />
    <input type="submit" value="Submit">
</form>
<?php
if (!function_exists('curl_version')) {
    echo 'Curl is not installed';
}

if ($_SERVER["REQUEST_METHOD"]=="POST") {
    // Required params
    $token = 'your_api_token';
    $stream_code = 'your_stream_code';

    // Fields to send
    $post_fields = [
        'stream_code'   => $stream_code,    // required
        'client'        => [
            'phone'     => $_POST['phone'], // required
            'name'      => $_POST['name'],
            // 'surname'   => $_POST['surname'],
            // 'email'     => $_POST['email'],
            // 'address'   => $_POST['address'],
            // 'ip'        => $_POST['ip'],
            // 'country'   => $_POST['country'],
            // 'city'      => $_POST['city'],
            // 'postcode'  => $_POST['postcode'],
        ],
        'sub1'      => (empty($_POST['sub1'])) ? $_GET['sub1'] : $_POST['sub1'],
        'sub2'      => (empty($_POST['sub2'])) ? $_GET['sub2'] : $_POST['sub2'],
        'sub3'      => (empty($_POST['sub3'])) ? $_GET['sub3'] : $_POST['sub3'],
        'sub4'      => (empty($_POST['sub4'])) ? $_GET['sub4'] : $_POST['sub4'],
        'sub5'      => (empty($_POST['sub5'])) ? $_GET['sub5'] : $_POST['sub5'],
    ];

    $headers = [
        'Content-Type: application/json',
        'Authorization: Bearer ' . $token
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,"https://order.drcash.sh/v1/order");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_fields));
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_HEADER, true);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    $body = substr($response, $header_size);

    curl_close ($ch);

    if ($httpcode != 200) {
        echo 'Error: ' . $httpcode;
        echo '<br>';
        echo $response;
    }
    if ($httpcode == 200) {
        echo '<script language="javascript" type="text/javascript">
            window.location.href = "./thanks";
        </script>';
    }
}
?>
</body>
</html>

Transferring subid

For a PHP archive and to add a LP to a tracker or a hosting/VPS/VDS and etc. It’s enough to add to every <form> tag a hidden input with the sub you need and the {clickid} macro. For example:
<input type="hidden" name="sub1" value="{clickid}">

For Keitaro - <input type="hidden" name="sub1" value="{subid}">


Also, find and edit the following piece of code in the index file
'sub1' => $_GET['sub1'] and change it to 'sub1' => $_POST['sub1'],

For a JS archive (if you upload an archive to a tracker), find the following piece of code in the index file:
sub1: drlead.queryGet("sub1"), and replace it with sub1: "{clickid}",

you can use any text editor to do it.