March 27, 201313 yr hi, I want to build an application in c++ that automatically send some data from client to a server on Internet. my website that must receive data is in php. how does PHP handle such applications? tnx
March 30, 201313 yr It looks as though you are looking for a REST API, this is where you have a specific URI or a number or URI’s for different functions (sending different data etc) and you utilise them through HTTP POST and GET requests. An example would be https://mysite.com/add/client , https://mysite.com/add/update/client , https://mysite.com/add/delete/client As such you would POST your data as variable name -> value pairs to a PHP script that would determine the action (add/update/delete) from the URL and will then use the data to perform the action. In PHP you will be interested in $_POST to retrieve the data. In C++ there are various libraries I’m sure... though my C++ is a little rusty, I believe libCurl is quite common based on a quick Google. You must however consider security, such that … what stops someone impersonating your application or listening in on the data you post as such I would recommend OAuth 2.0 and necessitate SSL for all communication. Some useful links:http://www.w3schools.com/php/php_post.asp < PHPhttp://www.restapitutorial.com/ < a useful what is rest guidehttp://oauth.net/ < OAuth
March 30, 201313 yr Author Restful APIs can become pretty troublesome. For instance, you may need to implement rate limiting, which brings into play loits of points and authentication. I'd highly advise Laravel as it supports restful routes/controllers out of the box using. E.g. a restful controller: class Api_Todos_Controller extends Base_Controller { public $restful = true; public function get_index($id = null) { // display the normal index for a standard GET request } public function post_index() { // handle a POST } public function put_index() { // handle a PUT request } public function delete_index($id = null) { // handle a DELETE } } Also, as abinus, you can return Eloquent models as Json, as simple as: return Response::eloquent( User::find(1) ); Sexy Tnx alot. I should work on it to see what these things are !
Create an account or sign in to comment