Connecting a desktop application with a website

2019-09-19 01:42发布

I made an application using Qt/C++ that reads some values every 5-7 seconds and sends them to a website.

My approach is very simple. I am just reading the values i want to send and then i make an HTTP POST to the website. I also send the username and password to the website.

The problem is that i cannot find out if the request is successful. I mean that if i send the request and server gets it, i will get an HTTP:200 always. For example if the password is not correct, there is no way to know it. It is the way HTTP works.

Now i think i will need some kind of a protocol to take care the communication between the application and the website.

The question is what protocol to use?

2条回答
爷的心禁止访问
2楼-- · 2019-09-19 02:13

if you can modify the server side script you could do the following

on one end : You can make the HTTP post request via ajax and evaluate the result of the ajax request.

On the serve side On the HTTP request you do your process and if everything goes accordingly you can send data back to the ajax script that called it.

solves your problem .. ?

查看更多
【Aperson】
3楼-- · 2019-09-19 02:22

If the action performed completes before the response header is sent you have the option of adding a custom status to it. If your website is built on PHP you can call header() to add the custom status of the operation.

header('XAppRequest-Status: complete');
查看更多
登录 后发表回答