This article explains how to use WordPress’s HTTP API, a set of PHP functions from within WordPress’s function library, to make remote HTTP requests to external resources, such as JSON REST APIs.
We use the WordPress HTTP API when we want to access remote resources—resources not present on the WordPress site we’re working from—which could be anything you can imagine, from data we access through Facebook’s or Twitter’s APIs to weather information published by government agencies. We make these remote requests using WordPress’s HTTP API functions, especially wp_remote_get()
, wp_remote_post()
, and wp_remote_head()
.
We’re proud to bring this article to you as a sample chapter from our full “learn WordPress development” guide Up and Running, now in its revised and expanded 3rd Edition.
If you like this chapter, check out Up and Running. There’s about 40 more chapters where this one came from. It’s the best guide to WordPress development out there.
Hi there
Thanks for this amazing post!
Is it possible to use these functions inside a separate project?
Example if I have a current Laravel written site and would like to post certain things to a WordPress site.
Would I need to add the “wp-includes” folder and use the functions?
This sounds like the work would need to be done within the wordpress side of things.
Thanks
Jenson