• 25-01-2020, 03:28:03
    #1
    <?php
    
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.uptimerobot.com/v2/getMonitors",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS => "api_key=u859463-xxxx&format=xml&custom_uptime_ratios=1-2-3-4-5-6-7-30",
    CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "content-type: application/x-www-form-urlencoded"
    ),
    ));
    
    
    $response = curl_exec($curl);
    $err = curl_error($curl);
    
    curl_close($curl);
    
    if ($err) {
    echo "cURL Error #:" . $err;
    } else {
    echo $response;
    }
    ?>
    yukarıdaki kod ile veriyi aşağıdaki gibi xml olarak alıyorum sizlerden ricam custom_uptime_ratio daki değerleri ayırarak almam gerekiyor "100.000-100.000-100.000-100.000-100.000-100.000-100.000-100.000" - işaretlerinden olanları 1. si 1. gün mesela 2. si 2. gün toplam 7 günün değeri var birde 30 gün bunları ayırabilir miyiz.

    <monitor id="784209035" friendly_name="NExxxOR-TR" url="xx.169.xx.66" type="4" sub_type="1" keyword_type="null" keyword_value="" http_username="" http_password="" port="80" interval="300" status="2" create_datetime="1579914764" custom_uptime_ratio="100.000-100.000-100.000-100.000-100.000-100.000-100.000-100.000" custom_down_durations="0-0-0-0-0-0-0-0"/>
  • 25-01-2020, 04:23:15
    #2
    Üyeliği durduruldu
    preg_match('/custom_uptime_ratio="(.*?)"/', $response, $results);
    $gunler = explode('-', $results[1]);
    print_r($gunler);


    Ek olarak;
    Verileri json formatında alırsanız daha kolay ayıklayabilirsiniz.
    format=json
  • 25-01-2020, 10:38:22
    #3
    <?php
    $xmlstr = <<<XML
    <?xml version='1.0' standalone='yes'?>
    <monitor id="784209035" friendly_name="NExxxOR-TR" url="xx.169.xx.66" type="4" sub_type="1" keyword_type="null" keyword_value="" http_username="" http_password="" port="80" interval="300" status="2" create_datetime="1579914764" custom_uptime_ratio="100.000-100.000-100.000-100.000-100.000-100.000-100.000-100.000" custom_down_durations="0-0-0-0-0-0-0-0"/>
    XML;
    
    $xml = new SimpleXMLElement($xmlstr);
    
    $get_custom_uptime_ratio = $xml[0]["custom_uptime_ratio"];
    
    $explode = explode("-", $get_custom_uptime_ratio);
    
    var_dump($explode);
    Sonuç olarak ;
    array (size=8)
      0 => string '100.000' (length=7)
      1 => string '100.000' (length=7)
      2 => string '100.000' (length=7)
      3 => string '100.000' (length=7)
      4 => string '100.000' (length=7)
      5 => string '100.000' (length=7)
      6 => string '100.000' (length=7)
     7 => string '100.000' (length=7)
    custom_uptime_ratio değerini parçalayıp array olarak tuttuk. $explode[0] ile ilk değere ulaşabilirsiniz.