Contoh Kode PHP

PROFIL
// Profil
$url_endpoint = "https://topupgaul.com/api/profile";
$postdata = http_build_query([
    'api_id' => 'apiid_anda',  // Ganti dengan API ID Anda
    'api_key' => 'apikey_anda', // Ganti dengan API Key Anda
    'action' => 'profile'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_endpoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$chresult = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);

$json_result = json_decode($chresult, true);

if (json_last_error() !== JSON_ERROR_NONE) {
    echo 'JSON decode error: ' . json_last_error_msg();
    exit;
}

if (isset($json_result['data'])) {
    $data = $json_result['data'];
    $username = isset($data['username']) ? $data['username'] : 'Tidak ada username';
    $saldo_sosmed = isset($data['saldo_sosmed']) ? $data['saldo_sosmed'] : 'Tidak ada saldo';
}

                                    
LAYANAN

// Layanan
$url_endpoint = "https://topupgaul.com/api/api_s1";
// $url_endpoint = "https://topupgaul.com/api/api_s2";
$postdata = http_build_query([
    'api_id' => 'apiid_anda',  // Ganti dengan API ID Anda
    'api_key' => 'apikey_anda', // Ganti dengan API Key Anda
    'action' => 'services'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_endpoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$chresult = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);

$json_result = json_decode($chresult, true);

if (json_last_error() !== JSON_ERROR_NONE) {
    echo 'JSON decode error: ' . json_last_error_msg();
    exit;
}

if (isset($json_result['data']) && is_array($json_result['data'])) {
    foreach ($json_result['data'] as $service) {
        $sid = isset($service['sid']) ? $service['sid'] : 'N/A';
        $kategori = isset($service['kategori']) ? $service['kategori'] : 'N/A';
        $layanan = isset($service['layanan']) ? $service['layanan'] : 'N/A';
        $harga = isset($service['harga']) ? $service['harga'] : 'N/A';
        $min = isset($service['min']) ? $service['min'] : 'N/A';
        $max = isset($service['max']) ? $service['max'] : 'N/A';
        $catatan = isset($service['catatan']) ? $service['catatan'] : 'N/A';
        $refill = isset($service['refill']) ? $service['refill'] : 'N/A';
        $average_time = isset($service['average_time']) ? $service['average_time'] : 'N/A';
    }
}

                                    
PEMESANAN

// Pemesanan
$url_endpoint = "https://topupgaul.com/api/api_s1";
// $url_endpoint = "https://topupgaul.com/api/api_s2";
$postdata = http_build_query([
    'api_id' => 'apiid_anda', // Ganti dengan API ID Anda
    'api_key' => 'apikey_anda', // Ganti dengan API Key Anda
    'layanan' => 'id_layanan', // Ganti dengan ID layanan yang sesuai
    'target' => 'target_pesanan', // Ganti dengan target pesanan yang sesuai
    'jumlah' => 'jumlah_pesanan', // Ganti dengan jumlah pesanan yang sesuai
    'custom_comments' => '', // Kosongkan jika tidak diperlukan, atau isi dengan komentar kustom
    'action' => 'orders'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_endpoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$chresult = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);

$json_result = json_decode($chresult, true);

if (json_last_error() !== JSON_ERROR_NONE) {
    echo 'JSON decode error: ' . json_last_error_msg();
    exit;
}

                                    
STATUS PEMESANAN

// Status Pemesanan
$url_endpoint = "https://topupgaul.com/api/api_s1";
// $url_endpoint = "https://topupgaul.com/api/api_s2";
$postdata = http_build_query([
    'api_id' => 'apiid_anda', // Ganti dengan API ID Anda
    'api_key' => 'apikey_anda', // Ganti dengan API Key Anda
    'id' => 'id_pesanan', // Ganti dengan ID pesanan yang sesuai
    'action' => 'status'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_endpoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$chresult = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);

$json_result = json_decode($chresult, true);

if (json_last_error() !== JSON_ERROR_NONE) {
    echo 'JSON decode error: ' . json_last_error_msg();
    exit;
}

                                    
REFILL PEMESANAN

// Refill Pemesanan
$url_endpoint = "https://topupgaul.com/api/api_s1";
// $url_endpoint = "https://topupgaul.com/api/api_s2";
$postdata = http_build_query([
    'api_id' => 'apiid_anda', // Ganti dengan API ID Anda
    'api_key' => 'apikey_anda', // Ganti dengan API Key Anda
    'id_order' => 'id_pesanan', // Ganti dengan ID pesanan yang sesuai
    'action' => 'refill'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_endpoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$chresult = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);

$json_result = json_decode($chresult, true);

if (json_last_error() !== JSON_ERROR_NONE) {
    echo 'JSON decode error: ' . json_last_error_msg();
    exit;
}

                                
STATUS REFILL

// Status Refill
$url_endpoint = "https://topupgaul.com/api/api_s1";
// $url_endpoint = "https://topupgaul.com/api/api_s2";
$postdata = http_build_query([
    'api_id' => 'apiid_anda', // Ganti dengan API ID Anda
    'api_key' => 'apikey_anda', // Ganti dengan API Key Anda
    'id_refill' => 'id_refill', // Ganti dengan ID refill yang sesuai
    'action' => 'refill_status'
]);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url_endpoint);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$chresult = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
    curl_close($ch);
    exit;
}

curl_close($ch);

$json_result = json_decode($chresult, true);

if (json_last_error() !== JSON_ERROR_NONE) {
    echo 'JSON decode error: ' . json_last_error_msg();
    exit;
}