Connecting a desktop application with a website

你。 提交于 2019-12-11 16:14:00

问题


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?


回答1:


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');



回答2:


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 .. ?



来源:https://stackoverflow.com/questions/6774200/connecting-a-desktop-application-with-a-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!