Contoh Kode PHP

PROFIL
// Profil
$url_endpoint = "https://vspedia.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'];
    $full_name = isset($data['full_name']) ? $data['full_name'] : 'Tidak ada full_name';
    $username = isset($data['username']) ? $data['username'] : 'Tidak ada username';
    $email = isset($data['email']) ? $data['email'] : 'Tidak ada email';
    $balance = isset($data['balance']) ? $data['balance'] : 'Tidak ada saldo';
}

                                    
LAYANAN

// Layanan
$url_endpoint = "https://vspedia.com/api/api_s1";
// $url_endpoint = "https://vspedia.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) {
        $service_id = isset($service['service_id']) ? $service['service_id'] : 'N/A';
        $name_category = isset($service['name_category']) ? $service['name_category'] : 'N/A';
        $name_service = isset($service['name_service']) ? $service['name_service'] : 'N/A';
        $min = isset($service['min']) ? $service['min'] : 'N/A';
        $max = isset($service['max']) ? $service['max'] : 'N/A';
        $price = isset($service['price']) ? $service['price'] : 'N/A';
        $note = isset($service['note']) ? $service['note'] : 'N/A';
        $button_refill = isset($service['button_refill']) ? $service['button_refill'] : 'N/A';
        $average_time = isset($service['average_time']) ? $service['average_time'] : 'N/A';
    }
}

                                    
PEMESANAN

// Pemesanan
$url_endpoint = "https://vspedia.com/api/api_s1";
// $url_endpoint = "https://vspedia.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
    'service' => 'id_layanan', // Ganti dengan ID layanan yang sesuai
    'target' => 'target_pesanan', // Ganti dengan target pesanan yang sesuai
    'quantity' => '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://vspedia.com/api/api_s1";
// $url_endpoint = "https://vspedia.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://vspedia.com/api/api_s1";
// $url_endpoint = "https://vspedia.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' => '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://vspedia.com/api/api_s1";
// $url_endpoint = "https://vspedia.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;
}