REST API client from external site

This is where the REST API is used to its maximum potential, even though we use it to build functionality of the same site. The main intention of creating a REST API is to provide access to third-party WordPress and non-WordPress based applications. So, the API client can be implemented in any programming language. In this section, we will be building a PHP based API client for accessing REST APIs of other applications with the support of CURL.

Let's add the API client implementation with CURL. You should place this code in a PHP file and access it from a source external to your application:

function wpquick_rest_api_client( $url, $post_data = '' ){  $api_route = $url;  $ch = curl_init( $api_route ); $headers ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.