I am trying to build a C++ application that syncs data from an existing PHP application ( which I have access to and can modify ) and is also capable of commiting changes to it. Data is not supposed to be accessed directly ( ie connecting to database from C++ ) because there's already a certain base code and also because of security concerns.

What I am trying to achieve requires a one-way communication. C++ ---> PHP should be enough and also helps keep it simple since the Apache server is constantly on.

I've been thinking about using cURL and call a PHP script. No problems there, but I am trying to determine what would the most reasonable way of exchanging data. I am familiar with JSON (jQuery) and have found it to be simple and robust.

However, C++ does not seem to have any standard way of dealing with JSON and while certain libraries do exist, clutter should be kept to a minimum.

The problem would be basically encoding and later parsing data. The C++ should be able to encode the data it sends and should be able to understand the response from PHP script.

Application and server will not be on the same machine and the C++ app should run both on Linux and Windows.

Any ideas on how to get these two to communicate?

有帮助吗?

解决方案

A good way to exchange messages is using XMLs in both ways. Since php got built-in XML parse functions and C data modeling using structs can be directly translated to XML tags, this kind of messaging can be an alternative.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top