• 15-05-2021, 21:43:26
    #10
    Buradaki HTML ve JavaScript kodlarını bonus olarak veriyorum umarım işinizi görür.

    index.html veya index.php
    <!DOCTYPE html>
    <html>
    <head>
        <title>Telegram</title>
        <link href="https://fonts.googleapis.com/css?family=Playfair+Display:400,500,600&subset=latin-ext" rel="stylesheet"/>
        <link rel="stylesheet" type="text/css" href="https://unpkg.com/nprogress@0.2.0/nprogress.css">
        <style type="text/css">
            body{font-family:'Playfair Display';font-size:14px;background-color:#f4f4f4}
            .box{max-width:760px;margin:0 auto;box-shadow:0 2px 4px 0 rgb(186 186 186 / 50%);background-color:#fff;border-radius:4px;margin-bottom:1em}
            .box.hide{display:none}
            .box-title{padding:15px 35px;border-bottom:1px solid #ddd;font-weight:500}
            .box-content{padding:35px}
            .box-info{border-top:1px solid #ddd;padding:15px 35px;font-size:12px}
            form .input{margin-bottom:1em}
            form .input label{display:block;font-weight:600;margin-bottom:5px}
            form .input input, form .input textarea{box-sizing:border-box;font:inherit;border:0;font-size:13px;border:1px solid #ddd;border-radius:3px;height:38px;border-radius:3px;padding:10px 15px;display:block;width:100%}
            form .input textarea{height:inherit}
            form .input input:focus, form .input textarea:focus{outline:none}
            form .input small{opacity:.5;font-size:12px}
            form button{box-sizing:border-box;font-family:inherit;font-size:13px;border-radius:4px;padding:10px 15px;border:0;color:#fff;font-weight:500;cursor:pointer;width:100%;background-color:#000;opacity:.2;cursor:not-allowed}
            form button.active{opacity:1;cursor:pointer;background-color:#1ABC9C}
            .channel{display:flex;margin-bottom:2em;align-items:center}
            .channel .image{width:80px;height:80px;background-color:#eee;margin-right:10px;background-size:100%}
            .channel .about strong{display:block;font-weight:600}
            .swal2-title{font-size:inherit!important}
            .swal2-content{font-size:inherit!important}
            .swal2-styled.swal2-confirm{font-size:13px!important;box-shadow:none!important}
            .swal2-actions button{margin-right:5px;box-shadow:none;text-shadow:none;border:0}
            .swal2-actions button:focus{box-shadow:none;outline:none}
            .swal2-actions button.swal2-styled{font-size:14px}
            .swal2-actions button:last-child{margin-right:0}
            .btn-danger{background-color:#C0392B}
            .btn-success{background-color:#27AE60}
            .swal2-actions .btn{margin-right:1em}
            .swal2-actions .btn:last-child{margin-right:0}
        </style>
    </head>
    <body>
        <div class="box" data-step="NewChannel">
            <div class="box-title">Yeni Kanal Ekle</div>
            <div class="box-content">
                <form>
                    <div class="input">
                        <label>Telegram davet bağlantısı (Örn: https://t.me/XXXXX şeklinde olmalıdır.)</label>
                        <input type="text" name="url" value="">
                        <small>'https://t.me/' ile birlikte girin.</small>
                    </div>
                    <button>Getir</button>
                </form>
            </div>
            <div class="box-info">
                <strong>Not:</strong> Telegram fotoğrafınız ve abone sayınız, neredeyse her gün otomatik olarak güncellenecek!
            </div>
        </div>
    
        <div class="box hide" data-step="Channel">
            <div class="box-title">Kanal Bilgileri</div>
            <div class="box-content">
                <form>
                    <div class="channel">
                        <div class="image"></div>
                        <div class="about">
                            <strong></strong>
                            <span></span>
                        </div>
                    </div>
                    <div class="input">
                        <label>İlan Adı</label>
                        <input type="text" name="title">
                        <small>45 karakterden az olmalı.</small>
                    </div>
                    <div class="input">
                        <label>Kısa Açıklama</label>
                        <textarea name="content"></textarea>
                        <small>Listeleme sayfasında kullanılmaktadır.</small>
                    </div>
                    <button>Tamamlandı</button>
                </form>
            </div>
        </div>
    
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js"></script>
        <script src="https://unpkg.com/nprogress@0.2.0/nprogress.js"></script>
        <script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
        <script>
            $("input[name=url]").bind("input", function(){
                $("[data-step=NewChannel] button").removeClass("active");
                if ($(this).val().substr(0,13) == 'https://t.me/' && $(this).val().length > 13) {
                    $("[data-step=NewChannel] button").addClass("active");
                }
            });
    
            $("[data-step=NewChannel] button").click(function(event){
                event.preventDefault();
                if ( ! $(this).hasClass("active")) return;
                $(this).removeClass("active");
    
                NProgress.configure({parent: '[data-step=NewChannel]'});
                NProgress.start();
                $.ajax({
                    url: "json.php",
                    type: "POST",
                    dataType: "JSON",
                    data: {url: $("input[name=url]").val()},
                    success: function(json){
                        NProgress.done();
                        if (json.status) {
                            if ( ! json.channel.total.members && ! json.channel.total.subscribers) {
                                Swal.fire({
                                    icon: 'error',
                                    title: 'Eklemeye çalıştığınız hesap kanal değil!',
                                    showConfirmButton: false,
                                    timer: 1500
                                });
                                return;
                            }
    
                            Swal.fire({
                                icon: 'success',
                                title: 'Kanal Bilgileri başarıyla çekilmiştir.',
                                showConfirmButton: false,
                                timer: 1500
                            });
    
                            $(".channel .image").css("background-image", "url(" + json.channel.image + ")");
                            $(".channel .about strong").text(json.channel.title);
                            $(".channel .about span").text(json.channel.total.members ? json.channel.total.members : json.channel.total.subscribers);
    
                            $("input[name=title]").val(json.channel.title);
                            $("textarea[name=content]").val(json.channel.title + " Telegram Kanalı");
    
                            $("[data-step=Channel]").slideDown();
                        } else {
    
                        }
                    }
                });
            });
        </script>
    </body>
    </html>
    json.php
    <?php
    header('Content-type: application/json');
    
    preg_match('#^https\:\/\/t\.me\/(.+?)$#si', $_POST['url']) OR exit(json_encode(array('status' => false, 'message' => 'Invalid URL')));
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $_POST['url']);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    $buffer = curl_exec($ch);
    $status = curl_errno($ch);
    curl_close($ch);
    
    
    if ($status) {
        exit(json_encode(array('status' => false, 'message' => curl_getinfo($ch))));
    }
    
    $buffer = str_replace(array("\t", "\r", "\n"), '', $buffer);
    $buffer = str_replace('> <', '><', $buffer);
    $buffer = str_replace('  ', '', $buffer);
    $buffer = str_replace('> <', '><', $buffer);
    $buffer = str_replace("\" />", "\"/>", $buffer);
    $buffer = str_replace(' dir="auto"', '', $buffer);
    
    // Members, Online, Subscribers
    preg_match('#<div class="tgme_page_extra">(.+?)</div>#si', $buffer, $match);
    
    $channel = $members = $online = $subscribers = $photo = '';
    
    if (isset($match[1])) {
        foreach (explode(', ', $match[1]) as $segment) {
            if (strpos($segment, 'members'))
                $members = (int) str_replace(' ', '', stristr($segment, ' members', true));
            elseif (strpos($segment, 'online'))
                $online = (int) str_replace(' ', '', stristr($segment, ' online', true));
            elseif (strpos($segment, 'subscribers'))
                $subscribers = (int) str_replace(' ', '', stristr($segment, ' subscribers', true));
        }
    }
    
    // Channel Name
    preg_match('#<div class="tgme_page_title"><span>(.+?)</span></div>#si', $buffer, $match);
    $channel = $match[1];
    
    // Channel Photo
    preg_match('#<img class="tgme_page_photo_image" src="(.+?)">#si', $buffer, $match);
    if (isset($match[1])) {
        $photo = $match[1];
    }
    
    // Structured Data
    $data = array(
        'status' => true,
        'channel' => array(
            'title' => $channel,
            'total' => array(
                'subscribers' => $subscribers,
                'members' => $members,
                'online' => $online
            ),
            'image' => $photo
        )
    );
    
    exit(json_encode($data));
    Sonuç;
  • 15-05-2021, 22:03:08
    #11
    Üyeliği durduruldu
    çok teşekkür ederim usta ellerine sağlık çalışıyor Allah razı olsun