• 23-03-2022, 05:58:25
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Selamlar arkadaşlar
    Bir script yaptım ve geliştirmeye çalışıyorum.

    Elimde şöyle bir kod var

    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, 'https://bunny.net/pullzone/12345/edgerules/addOrUpdate');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"ActionType\":1,\"ActionParameter1\":\"https://example.com\",\"ActionParameter2\":\"\",\"Triggers\":[{\"Type\":4,\"PatternMatchingType\":0,\"Parameter1\":\"\",\"PatternMatches\":[\"TR\"]}],\"TriggerMatchingType\":2,\"Enabled\":true}");
    
    $headers = array();
    $headers[] = 'Accept: application/json';
    $headers[] = 'AccessKey: xxxxxxxxxx';
    $headers[] = 'Content-Type: application/json';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        echo 'Error:' . curl_error($ch);
    }
    curl_close($ch);
    Şimdi ben bir form oluşturmak istiyorum
    o form da 2 tane alan istiyorum alanın bir tanesine yazdığım veriyi yukarıdaki https://example.com olan yerdelki ile değiştirsin istiyorum.
    2. alana yazdığım veriyide 12345 olan yere eşitleeyip post ettirmek istiyorum. yardımlarınızı bekliyorum teşekkürler.
  • 23-03-2022, 07:37:52
    #2
    Developer
    <?php
    if(isset($_POST['submit'])){
    $var1 = $_POST['var1'];
    $var2 = $_POST['var2'];
    
    $ch = curl_init();
    
    curl_setopt($ch, CURLOPT_URL, 'https://bunny.net/pullzone/'.$var1.'/edgerules/addOrUpdate');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, '{"ActionType":1,"ActionParameter1":"'.$var2.'","ActionParameter2":"","Triggers":[{"Type":4,"PatternMatchingType":0,"Parameter1":"","PatternMatches":["TR"]}],"TriggerMatchingType":2,"Enabled":true}');
    
    $headers = array();
    $headers[] = 'Accept: application/json';
    $headers[] = 'AccessKey: xxxxxxxxxx';
    $headers[] = 'Content-Type: application/json';
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    
    $result = curl_exec($ch);
    if (curl_errno($ch)) {
    $dump = 'Error:' . curl_error($ch);
    }else{
    $dump = $result;
    }
    curl_close($ch);
    }
    ?>
    <form method="post" action="#">
    <input type="text" name="var1">
    <input type="text" name="var2">
    <input type="submit" name="submit">
    </form>
    
    <?php if(isset($dump)): ?>
    <pre>
    <?php var_dump($dump); ?>
    </pre>
    <?php endif; ?>
  • 23-03-2022, 11:16:08
    #3
    hemen deniyorum çok teşekkürler @brown;
  • 23-03-2022, 11:19:48
    #4
    @brown; ekrana string(0) "" yazdı eklemedi