PHP code example of webdevstudios / wds-wp-rest-api-connect

1. Go to this page and download the library: Download webdevstudios/wds-wp-rest-api-connect library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webdevstudios / wds-wp-rest-api-connect example snippets


// Make sure you run `composer install`!
wds-wp-rest-api-connect.php' );

// Get the connect object
$api_connect = new WDS_WP_REST_API\OAuth1\Connect();

// Client credentials
$client = array(

	// Library will 'discover' the API url
	'api_url' => 'WP SITE URL TO CONNECT TO',

	// App credentials set up on the server
	'client_key' => 'YOUR CLIENT KEY',
	'client_secret' => 'YOUR CLIENT SECRET',

	// Must match stored callback URL setup on server.
	'callback_uri' => admin_url() . '?api-connect',
);

/*
 * Initate the API connection.
 *
 * if the oauth connection is not yet authorized, (and autoredirect_authoriziation
 * is not explicitly set to false) you will be auto-redirected to the other site to
 * receive authorization.
 */
$discovery = $api_connect->init( $client );