Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php, how to recieve data from client application

Featured Replies

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

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 < PHP
http://www.restapitutorial.com/ < a useful what is rest guide
http://oauth.net/ < OAuth


  • 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.