[Solved] How to do a PHP curl post [closed]


// init curl

$handle = curl_init();

// set options/parameters

curl_setopt( $handle, CURLOPT_URL,              'https://developer.lametric.c...');
curl_setopt( $handle, CURLOPT_CUSTOMREQUEST,    "POST");
curl_setopt( $handle, CURLOPT_POSTFIELDS,       'the-json-encoded-data-here' );
curl_setopt( $handle, CURLOPT_RETURNTRANSFER,   true ); // you want to get the response

// set headers 

curl_setopt( $handle, CURLOPT_HTTPHEADER,       array(  'Accept: application/json',
                                                        '....' ) );
// execute the request and get the response

$response = curl_exec( $handle );

// get the status too

$status = curl_getinfo( $handle, CURLINFO_HTTP_CODE );

// release resources

curl_close( $handle );

Just an example/introduction.

You initialize php’s curl.

Setup all the parameters.

Send the request.

I won’t write all the code for you.

PHP Reference is clear (and have examples too)

http://php.net/manual/en/book.curl.php

SO have examples too:

PHP + curl, HTTP POST sample code?

solved How to do a PHP curl post [closed]