WordPress has several functions for sending requests via PHP, including wp_remote_post()
, which you can use to send a POST request to an API. Then you can use wp_remote_retrieve_body()
to handle the response. It would look something like:
$response = wp_remote_post( 'http://example.org/api' );
$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
If you need to interact with the API via JavaScript, then WordPress doesn’t get involved, and you would do it the same way you’d do it any any JavaScript application.
Related Posts:
- This page didn’t load Google Maps correctly. See the JavaScript console for technical details
- This page didn’t load Google Maps correctly. See the JavaScript console for technical details
- Constructing requests with URL Query String in Python
- Is there a developers api for craigslist.org
- WordPress Rest API custom endpoint optional param
- Access WordPress API Outside of WordPress (command-line PHP)
- Create API for single sign-on with 3rd party site
- What is the best way to get directory path for wp-config.php?
- Retrieving pages with multiple tags using REST API
- External WordPress API
- How do I use the WP REST API plugin and the OAuth Server plugin to allow for registration and login?
- Sending POST Request from server
- List Table API – Safe to use?
- API integration with WordPress
- POST to a REST API from a wordpress form
- get WP-API by page id
- Custom route for WP-API gives “rest_no_route” value
- Get more than 10 posts in a specific category with the wordpress api
- “rest_no_route” – Debug error
- Passing variables to new page
- utf8 encoding in json rest api
- Implementing the wp json-rest api
- How to Securely and remotely Create new user in wordpress using Rest API
- API in numbers?
- Does WordPress support a shortcode calling itself from within a shortcode call?
- What is the official way to consume the WordPress API? (api.wordpress.org)
- Stuck with wp_remote_post sending data to an external api on user registration
- How to get title tag of an external page with http api?
- How to Increase WordPress JSON API Speed?
- WordPress JSON API Extend to Create Users [closed]
- External API to WP
- Headless WordPress – Issue with plugin path
- Can’t get POST data in API endpoint callback
- node-wpapi: how to handle authentication?
- Post body not working with wp_remote_post()
- Adding rest api endpoints to an old theme
- Develop REST API using WordPress for Android app [closed]
- Integrate ZOHO Recruit API?
- Allow logged in WordPress user to access 3rd party Laravel API via OAuth
- are there any initiatives to work wordpress as microservices?
- Sanitize Disqus API results?
- Best Practice for re-using API Data in WordPress?
- For using google api is it necessary to install the google client libraries for using Oauth 2 in wordpress installation?
- WordPress Google Calendar Oath 404
- Get non-rendered content from WP-API
- Calling an API to do authentication / user login
- Add basic authentication of WordPress on any external PHP file?
- cURL to install theme
- Enabling CORS with WordPress
- How do I query my WordPress posts on another HTML page using the WordPress Restful API?
- body_class REST field in WP-API
- Authenticating a user with the WP-API V2 in Postman
- WP OAuth Server “The grant type was not specified in the request”
- Submit comment via JSON from Android device
- WordPress keeps autoplaying my Youtube-Links no matter what I write
- Save external API calls in WordPress
- How to add an endpoint for my custom post type? /wp-json/wp/v2/posts is working but it didn’t in the custom post
- Integrating API in to WordPress
- How to convert and use JSON data from a remote WordPress server?
- JSON API and notification about registration
- How to get the post_id after you successfully create new post using xmlrpc api wp newPost?
- Where to put API Code?
- Implement External API into WordPress [closed]
- Integrate WooCommerce to PromoSoftware Rest API
- hybridauth (google OAuth integration) and WP problems
- term_exists returns NULL
- Consuming an external API to publish/post to wordpress
- Set up WP Authentication from External API
- WordPress API Create post content
- How to queue API requests with PHP in WordPress?
- WordPress API causing fatal error
- WordPress Theme/Plugin Information API Response to Text and Button
- Composer Installed Package with WordPress Rest API Endpoint
- Is there a way to get Google My Business photos on WordPress with the API or other?
- Call external API
- How to use filters/params in wordpress as headless cms api
- WordPress json rest api displaying 10 categories only
- Creating posts, containing data from remote API
- Passing data outside of WordPress possible?
- Periodically Query an external API on wordpress site
- Post to WordPress API using cURL and login cookies
- Extending the API I created to return category names
- Rest WP_Error always return null
- Using the JSON API via HTTPS and HTTP
- Posting data from Ionic app to WordPress
- WordPress REST API Endpoint (Authors and Categories latest posts)
- Instructure Canvas API with WordPress [closed]
- Best way to make a JSON API from WordPress?
- Encrypt API key [duplicate]
- Can I get the post id when trying to make a new post using xmlrpc?
- Using PHP Api wrapper within plugin. Wrapper uses name space
- REST API And Error Codes – No Message
- Querying Posts Using JSON API
- basic wordpress api endpoint to serve a key-value dictionary
- Is it possible to make website content available on another website?
- How to login via wordpress api and get user details?
- Send Order Confirmation automatically to customer’s mobile number
- How many users/load can the rest API handle?
- How get JSON from external API on every page load if not existing in transient?
- XMLRPC: How to retrieve possible custom fields for a new post?