CURL-less method with PHP5:
$url = 'http://server.com/path'; $data = array('key1' => 'value1', 'key2' => 'value2'); // use key 'http' even if you send the request to https://... $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); if ($result === FALSE) { /* Handle error */ } var_dump($result);
See the PHP manual for more information on the method and how to add headers, for example:
- stream_context_create: http://php.net/manual/en/function.stream-context-create.php
Related Posts:
- How are parameters sent in an HTTP POST request?
- What is the difference between POST and GET? [duplicate]
- application/x-www-form-urlencoded or multipart/form-data?
- application/x-www-form-urlencoded or multipart/form-data?
- What’s the difference between a POST and a PUT HTTP REQUEST?
- What’s the difference between “Request Payload” vs “Form Data” as seen in Chrome dev tools Network tab
- Setting Curl’s Timeout in PHP
- What is the difference between POST and PUT in HTTP?
- What is the difference between POST and PUT in HTTP?
- Should a 502 HTTP status code be used if a proxy receives no response at all?
- What is the difference between a URI, a URL and a URN?
- HTTP Status 504
- Do I need Content-Type: application/octet-stream for file download?
- Problem HTTP error 403 in Python 3 Web Scraping
- Problem HTTP error 403 in Python 3 Web Scraping
- Is 418 “I’m a teapot” really an HTTP response code?
- How to define the basic HTTP authentication using cURL correctly?
- PHP 7.2 – Warning: count(): Parameter must be an array or an object that implements Countable
- How to fix ‘Notice: Undefined index:’ in PHP form action
- How to define the basic HTTP authentication using cURL correctly?
- “Cannot GET /” with Connect on Node.js
- “CAUTION: provisional headers are shown” in Chrome debugger
- PHP + curl, HTTP POST sample code?
- Why is it said that “HTTP is a stateless protocol”?
- What’s the difference between using application/csv vs text/csv? [duplicate]
- Make a HTTPS request through PHP and get response
- How is an HTTP POST request made in node.js?
- What are all the possible values for HTTP “Content-Type” header?
- How to read if a checkbox is checked in PHP?
- What is the difference between PUT, POST and PATCH?
- curl POST format for CURLOPT_POSTFIELDS
- Exception in thread “main” java.net.NoRouteToHostException: No route to host
- PHP $_POST not working?
- ndroid 8: Cleartext HTTP traffic not permitted
- How to send a GET request from PHP?
- Can PHP cURL retrieve response headers AND body in a single request?
- Why am I suddenly getting a “Blocked loading mixed active content” issue in Firefox?
- wget: unable to resolve host address `http’
- Are HTTP headers case-sensitive?
- Sending POST data without form
- PHP Redirect with POST data
- When looking at the differences between X-Auth-Token vs Authorization headers, which is preferred?
- POST an array from an HTML form without javascript
- Query multiple WordPress post types alternately
- update post meta wordpress
- WordPress HTTP parameter pollution
- Does WordPress send data about your blog to WordPress.org or Automattic?
- Hiding WordPress REST API v2 endpoints from public viewing
- Where to get information about array fields in $_REQUEST?
- Does WordPress only support HTTP 1.1?
- How do I troubleshoot responses with WP HTTP API?
- Is curl required?
- How to set status codes such as 401 and 403?
- The resource was preloaded using link preload but not used within a few seconds
- Why Better WP security plugin returns 418 I’m a Teapot “error”?
- using wp_remote_get to retrieve own url on local host
- Can I use HTTP POSTs? Is there a better alternative?
- Warning: Use of undefined constant HTTP_USER_AGENT – assumed ‘HTTP_USER_AGENT’ (this will throw an Error in a future version of PHP)
- Using wp-cron in backpress – problems with wp_remote_post, fsockopen error
- Is there an equivalent to WP_Error object I can return in the case of a successful REST request?
- Running index.php from command line & load balancer health checks
- Enable CORS in wordpress
- Change port of wordpress
- How to get value of custom http header?
- Several times request to load plugins when sending one request
- why is $_REQUESt[‘redirect_to’] empty?
- I am receiving a pluggable.php warning sign on my only http:// page
- Local WordPress with WAMP downloads files out of Nowhere
- Reading URL Parameters
- Display values of current POST request on page
- Get “HTTP/1.1 406 Not Acceptable” when accesing my website with Delphi Indy Control
- Sudden Upload HTTP errors, PHP uploads and memory limits are already to high to my taste. Anything else?
- Require advice handling a URL redirect from a Third Party. URL Params need to populate and then forward to payment
- WordPress HTTP 500 Error “page isn’t working”
- My WP Website Shows HTTP ERROR 500
- Using the wp_remote_post response body
- What’s the point in having “www” in a URL?
- For what is the “.well-known”-folder?
- Human readable format for http headers with tcpdump
- How to make wireshark filter POST-requests only?
- Image file urls still point to http instead of https
- WordPress is removing http:// from my urls
- Encountering 400 Bad Request Error When Sending Form Information to API through Elementor
- Error in php code
- How to create categories out of a list of words?
- How can i give a download link to the thumbnail or featured image
- add if statement to the featured image
- WordPress White Screen Error
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- How to handle parent and child pages?
- How can I prevent wordpress from sending emails
- Fast Tranfering my WordPress site to another server
- Get Products within Current Product Category
- Category slug inside another php code
- Options.php loop won’t show!
- Wrapping the_content() in Schema articleBody tag? [closed]
- Infinite Scroll Plugin: How to first show 6 posts and then 2 posts thereafter with Infinite Scroll Plugin?
- http upload error as a subscribed user
- Duplicating wordpress install issue
- Millennial Media PHP Setup ( Code Integration )