Fipy, Lopy, Wipy Http Post?



  • How do I transfer data so that I can retrieve it on a web server like this?
    <?php
    //Sensor1
    $p1 = $_GET["p1"];
    $p2 = $_GET["p2"];
    $p3 = $_GET["p3"];
    $p4 = $_GET["p4"];
    $p5 = $_GET["p5"];

    $p6 = $_GET["p6"];
    $p7 = $_GET["p7"];
    $p8 = $_GET["p8"];
    $p9 = $_GET["p9"];
    $p10 = $_GET["p10"];

    $p11 = $_GET["p11"];
    $p12 = $_GET["p12"];
    $p13 = $_GET["p13"];
    $p14 = $_GET["p14"];
    $p15 = $_GET["p15"];

    $p16 = $_GET["p16"];
    $p17 = $_GET["p17"];
    $p18 = $_GET["p18"];
    $p19 = $_GET["p19"];
    $p20 = $_GET["p20"];

    $inhalt = array($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, $p10, $p11, $p12, $p13, $p14, $p15, $p16, $p17, $p18, $p19, $p20);
    // Speichern der Datei
    $eintrag = implode(";", $inhalt);
    file_put_contents("sensor1.txt", $eintrag);
    ?>

    Translated with www.DeepL.com/Translator



  • @Martinnn i have been trying to use urequests for HTTP POST and i always receive the error msg that the function accepts only 2 positional args while it gets 4 (or something along that line). have seen may msg in various fora about that error, but never found a turn-around that worked for me.



  • Das funktioniert leider nicht.

    import requests
    userdata = {"firstname": "John", "lastname": "Doe", "password": "jdoe123"}
    resp = requests.post('http://yourserver.de/test.php', params=userdata)
    Your PHP-File:

    $firstname = htmlspecialchars($_GET["firstname"]);
    $lastname = htmlspecialchars($_GET["lastname"]);
    $password = htmlspecialchars($_GET["password"]);
    echo "firstname: $firstname lastname: $lastname password: $password";
    firstname: John lastname: Doe password: jdoe123



  • @martinnn said in Fipy, Lopy, Wipy Http Post?:

    Not sure what you are trying to do...
    As you write "POST" in your title - are you aware of the urequrests library (which provides http/https put, get, post...)?

    Yes, I know the library, but I don't know how to use it to send it to my webserver via post command and then get it via PHP.
    I'm new to Python.



  • Not sure what you are trying to do...
    As you write "POST" in your title - are you aware of the urequrests library (which provides http/https put, get, post...)?



  • Please help me!


Log in to reply
 

Pycom on Twitter