• 02-04-2022, 11:39:15
    #1
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Merhaba arkadaşlar,
    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.
  • 02-04-2022, 11:44:33
    #2
    if (isset($_POST)) {
    
    
    
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://bunny.net/pullzone/'.$_POST["birkikiuc"].'/edgerules/addOrUpdate');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"ActionType\":1,\"ActionParameter1\":\"".$_POST["site_adresi"]."\",\"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);
    
    }
    <form>
    <input *>
    <input *>
    <input *>
    </form>
  • 02-04-2022, 11:52:09
    #3
    oktayc0 adlı üyeden alıntı: mesajı görüntüle
    if (isset($_POST)) {
    
    
    
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://bunny.net/pullzone/'.$_POST["birkikiuc"].'/edgerules/addOrUpdate');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"ActionType\":1,\"ActionParameter1\":\"".$_POST["site_adresi"]."\",\"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);
    
    }
    <form>
    <input *>
    <input *>
    <input *>
    </form>
    üstadım teşekkürler form olştururken post edeceği değişkenleri birukuc ve site_adresi diye mi oluşturacağım ?
  • 02-04-2022, 12:07:12
    #4
    orhnb adlı üyeden alıntı: mesajı görüntüle
    üstadım teşekkürler form olştururken post edeceği değişkenleri birukuc ve site_adresi diye mi oluşturacağım ?
    Evet, Örn:

    <form action="" method="POST">
    <input type="text" name="birikiuc">
    <input type="text" name="site_adresi">
    <input type="submit">
    </form>
  • 02-04-2022, 12:16:05
    #5
    oktayc0 adlı üyeden alıntı: mesajı görüntüle
    Evet, Örn:

    <form action="" method="POST">
    <input type="text" name="birikiuc">
    <input type="text" name="site_adresi">
    <input type="submit">
    </form>
    Dediğiniz gibi yaptım ama post etmedi bi hata yapmış olabilir miyim? şu şekilde hazırladım sayfayı en basitinden.
    <?
    
    
     include 'bunnycdn.php';
     $key = "41c80cf2-a8fc-4a75-85c9-fe48f54d76c78cbe6d3e-b6ab-4668-8b45-bac59b7b6115";
    if (isset($_POST)) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://bunny.net/pullzone/'.$_POST["birkikiuc"].'/edgerules/addOrUpdate');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"ActionType\":1,\"ActionParameter1\":\"".$_POST["site_adresi"]."\",\"ActionParameter2\":\"\",\"Triggers\":[{\"Type\":4,\"PatternMatchingType\":0,\"Parameter1\":\"\",\"PatternMatches\":[\"TR\"]}],\"TriggerMatchingType\":2,\"Enabled\":true}"); $headers = array(); $headers[] = 'Accept: application/json'; $headers[] = 'AccessKey: 41c80cf2-a8fc-4a75-85c9-fe48f54d76c78cbe6d3e-b6ab-4668-8b45-bac59b7b6115'; $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);
    }
    
    
    ?>
    <form action="" method="POST">
    <input type="text" name="birikiuc">
    <input type="text" name="site_adresi">
    <input type="submit">
    </form>
  • 02-04-2022, 12:39:35
    #6
    Şu kodları denedim çalıştı ama php ile form ile post ettiremiyorum

    curl --request POST \
         --url https://api.bunny.net/pullzone/747810/edgerules/addOrUpdate \
         --header 'AccessKey: 41c80cf2-a8fc-4a75-85c9-fe48f54d76c78cbe6d3e-b6ab-4668-8b45-bac59b7b6115' \
         --header 'Content-Type: application/json' \
         --data '
    {
         "Triggers": [
              {
                   "PatternMatches": [
                        "TR"
                   ],
                   "Type": 4,
                   "PatternMatchingType": 0
              }
         ],
         "ActionType": 1,
         "TriggerMatchingType": 2,
         "Enabled": true,
         "ActionParameter1": "https://google.com"
    }
    '