I know it's probably a big question, so I am fine with someone just telling me where to begin so I can piece things together.
I have a command line tool where I want to know how often it's used. If it's started, I want to send a signal to my php server, that writes it into a mysql database. I know how to write to a database, but I don't know how to connect a rust program, through the web, using http to tell the php server: "Hey, the Program you have written 10 years ago has just been executed!".
Also if you don't want to use async and pull in a runtime, you can use a sync client like ureq. Just make sure to make the request in a separate thread so your cli doesn't feel slow.
How would I do this using ureq?
I am fairly new to the internals of Http.
I get a
Response[status: 400, status_text: Dns Failed]
Pinging my server works however as well as reading it using the browser
This is what I have
let resp = ureq::post("https://192.168.0.4:8080/test/post_usage.php")
.set("id", "1")
.call();
println!("{:?}", resp);
with the "id" specifying the variable i want to read with php via $_POST['id']
EDIT 1:
I should have removed the 's' from 'https'. I forgot to remove it by copying the example.
But I think I shouldn't be using the set command for setting variables
EDIT 2:
Ok one has to use .send_form() command instead of the .set() command. Man how glad I am the code on github is so well documented. Thanks for the suggestions.
What about reqwest::blocking
?
That could work too. It is still using Futures underneath. But I guess as a user you don't have to think about it and you don't need a runtime.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.