I work extensively with APIs and a variety of serverside scripting languages, and best practice does change over time. Many of the most popular posts on my blog are10 years old because apparently, I was interesting in 2008. Two in particular from around that time relate to making POST requests from PHP, and I’d do it completely differently today. So, in an attempt to overcome some of the past crimes of the Internet in general and PHP in particular: here’s how to make a POST request in PHP, today, in a PHP 7+ world (it probably works in PHP 5 too).
Dependencies: GuzzleHTTP
Guzzle is brilliant. If you make web requests with PHP, use Guzzle. Guzzle actually does a bunch of other things too, but today, we’re making a POST request. https://goo.gl/yse3dE
Share this:
- Click to share on Facebook (Opens in new window)
- Click to share on Twitter (Opens in new window)
- Click to email a link to a friend (Opens in new window)
- Click to share on LinkedIn (Opens in new window)
- Click to share on Tumblr (Opens in new window)
- Click to share on Pinterest (Opens in new window)
- Click to share on Reddit (Opens in new window)