You can post json data to server using curl in following way
-H "Accept: application/json"
-X POST -d "$txt" "http://username:email@example.com"
(HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more
(HTTP) Extra header to include in the request when sending HTTP to a server. You may specify any number of extra headers. Note that if you should add a custom header that has the same name as one of the internal ones curl would use, your externally set header will be used instead of the internal one. This allows you to make even trickier stuff than curl would normally do. You should not replace internally set headers without knowing perfectly well what you’re doing. Remove an internal header by giving a replacement without content on the right side of the colon, as in: -H “Host:”. If you send the custom header with no-value then its header must be terminated with a semicolon, such as -H “X-Custom-Header;” to send “X-Custom-Header:”.
(HTTP) Specifies a custom request method to use when communicating with the HTTP server. The specified request method will be used instead of the method otherwise used (which defaults to GET). Read the HTTP 1.1 specification for details and explanations. Common additional HTTP requests include PUT and DELETE, but related technologies like WebDAV offers PROPFIND, COPY, MOVE and more.
(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F, –form.
for more details look at curl man page
To receive post contents on webserver using PHP follow the link below
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET http://hostname/resource
Post Simple Data
curl --data "param1=value1&param2=value2" http://hostname/resource
Restful HTTP POST
curl -X POST -d @filename http://hostname/resource
Uploading File using Curl
curl --form "firstname.lastname@example.org" http://hostname/resource