• 02-03-2024, 14:37:01
    #1
    Selamlar
    Bitexen de json kullanarak kripto paritelerini sırasıyla ekrana yazmak istiyorum.Örn;

    BTCTRY
    ETHTRY
    USDTTRY gibi

    https://www.bitexen.com/api/v1/ticker/ bu linkte tüm bilgiler mevcut
  • 02-03-2024, 14:40:30
    #2
    fetch('https://www.bitexen.com/api/v1/ticker/')
        .then(response => {
            if (!response.ok) {
                throw new Error('API\'ye erişilemedi. HTTP status code: ' + response.status);
            }
            return response.json();
        })
        .then(data => {
            const btctry_data = data.BTCTRY;
            const ethtry_data = data.ETHTRY;
            const usdttry_data = data.USDTTRY;
    
            console.log("BTCTRY verileri:", btctry_data);
            console.log("ETHTRY verileri:", ethtry_data);
            console.log("USDTTRY verileri:", usdttry_data);
        })
        .catch(error => {
            console.error('Hata:', error);
        });
  • 02-03-2024, 14:41:05
    #3
    merhabalar bunu siteyemi yazdırmak istiyorsunuz?
  • 02-03-2024, 14:43:43
    #4
    Misafir adlı üyeden alıntı: mesajı görüntüle
    fetch('https://www.bitexen.com/api/v1/ticker/')
        .then(response => {
            if (!response.ok) {
                throw new Error('API\'ye erişilemedi. HTTP status code: ' + response.status);
            }
            return response.json();
        })
        .then(data => {
            const btctry_data = data.BTCTRY;
            const ethtry_data = data.ETHTRY;
            const usdttry_data = data.USDTTRY;
    
            console.log("BTCTRY verileri:", btctry_data);
            console.log("ETHTRY verileri:", ethtry_data);
            console.log("USDTTRY verileri:", usdttry_data);
        })
        .catch(error => {
            console.error('Hata:', error);
        });
    Hocam php dilinde yapabilirmisiniz.JS biraz uzağım
  • 02-03-2024, 14:45:58
    #5
    Misafir adlı üyeden alıntı: mesajı görüntüle
    merhabalar bunu siteyemi yazdırmak istiyorsunuz?
    sadece echo ve print ile ekrana yazdırmak istiyorum
  • 02-03-2024, 14:52:41
    #6
    gelir_ortagim adlı üyeden alıntı: mesajı görüntüle
    sadece echo ve print ile ekrana yazdırmak istiyorum

    <?php
    
    $url = 'https://www.bitexen.com/api/v1/ticker/';
    
    $options = [
        'http' => [
            'method' => 'GET',
            'header' => 'Content-Type: application/json'
        ]
    ];
    
    $context = stream_context_create($options);
    $response = file_get_contents($url, false, $context);
    
    if ($response === false) {
        die('API\'ye erişilemedi.');
    }
    
    $data = json_decode($response, true);
    
    if ($data === null || !isset($data['status']) || $data['status'] !== 'success' || !isset($data['data']['ticker'])) {
        die('API yanıtı geçersiz veya beklenmeyen bir formatta.');
    }
    
    $ticker_data = $data['data']['ticker'];
    
    foreach (['ETHTRY', 'BTCTRY','USDTTRY'] as $pair) {
        if (isset($ticker_data[$pair])) {
            $pair_data = $ticker_data[$pair];
            echo "Market: $pair<br>";
            echo "Bid: " . $pair_data['bid'] . "<br>";
            echo "Ask: " . $pair_data['ask'] . "<br>";
            echo "Last Price: " . $pair_data['last_price'] . "<br>";
            echo "Last Size: " . $pair_data['last_size'] . "<br>";
            echo "Volume 24h: " . $pair_data['volume_24h'] . "<br>";
            echo "Change 24h: " . $pair_data['change_24h'] . "<br>";
            echo "Low 24h: " . $pair_data['low_24h'] . "<br>";
            echo "High 24h: " . $pair_data['high_24h'] . "<br>";
            echo "Avg 24h: " . $pair_data['avg_24h'] . "<br>";
            echo "Timestamp: " . date('Y-m-d H:i:s', $pair_data['timestamp']) . "<br>";
            echo "<br>";
        }
    }
    
    ?>
    • gelir_ortagim
    gelir_ortagim bunu beğendi.
    1 kişi bunu beğendi.
  • 02-03-2024, 15:00:05
    #7
    Misafir adlı üyeden alıntı: mesajı görüntüle
    <?php
    
    $url = 'https://www.bitexen.com/api/v1/ticker/';
    
    $options = [
        'http' => [
            'method' => 'GET',
            'header' => 'Content-Type: application/json'
        ]
    ];
    
    $context = stream_context_create($options);
    $response = file_get_contents($url, false, $context);
    
    if ($response === false) {
        die('API\'ye erişilemedi.');
    }
    
    $data = json_decode($response, true);
    
    if ($data === null || !isset($data['status']) || $data['status'] !== 'success' || !isset($data['data']['ticker'])) {
        die('API yanıtı geçersiz veya beklenmeyen bir formatta.');
    }
    
    $ticker_data = $data['data']['ticker'];
    
    foreach (['ETHTRY', 'BTCTRY','USDTTRY'] as $pair) {
        if (isset($ticker_data[$pair])) {
            $pair_data = $ticker_data[$pair];
            echo "Market: $pair<br>";
            echo "Bid: " . $pair_data['bid'] . "<br>";
            echo "Ask: " . $pair_data['ask'] . "<br>";
            echo "Last Price: " . $pair_data['last_price'] . "<br>";
            echo "Last Size: " . $pair_data['last_size'] . "<br>";
            echo "Volume 24h: " . $pair_data['volume_24h'] . "<br>";
            echo "Change 24h: " . $pair_data['change_24h'] . "<br>";
            echo "Low 24h: " . $pair_data['low_24h'] . "<br>";
            echo "High 24h: " . $pair_data['high_24h'] . "<br>";
            echo "Avg 24h: " . $pair_data['avg_24h'] . "<br>";
            echo "Timestamp: " . date('Y-m-d H:i:s', $pair_data['timestamp']) . "<br>";
            echo "<br>";
        }
    }
    
    ?>
    Sağolun hocam.işime yaradı
  • 02-03-2024, 15:02:30
    #8
    gelir_ortagim adlı üyeden alıntı: mesajı görüntüle
    Hocam php dilinde yapabilirmisiniz.JS biraz uzağım
    <?php
    $url = 'https://www.bitexen.com/api/v1/ticker/';
    $response = file_get_contents($url);
    
    if ($response === false) {
        die('API\'ye erişilemedi.');
    }
    
    $data = json_decode($response, true);
    
    if ($data === null) {
        die('Geçersiz JSON yanıtı.');
    }
    
    $btctry_data = $data['BTCTRY'];
    $ethtry_data = $data['ETHTRY'];
    $usdttry_data = $data['USDTTRY'];
    
    echo "BTCTRY verileri: ";
    print_r($btctry_data);
    echo "\n";
    
    echo "ETHTRY verileri: ";
    print_r($ethtry_data);
    echo "\n";
    
    echo "USDTTRY verileri: ";
    print_r($usdttry_data);
    echo "\n";
    ?>