PHP code example of joeybeninghove / json-api-wp-client
1. Go to this page and download the library: Download joeybeninghove/json-api-wp-client 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/ */
joeybeninghove / json-api-wp-client example snippets
class Invoice extends Json_Api_Wp_Resource
{
public function __construct()
{
parent::__construct(
"https://api.site.com/v1/", // base URL
"invoices" // type
)
}
}
Json_Api_Wp_Resource::auth( "jdoe", "secret" );
class Base extends Json_Api_Wp_Resource
{
public function __construct( $type )
{
parent::__construct( "http://api.site.come/v1/", $type );
}
public static function set_api_key( $api_key )
{
parent::auth( $apiKey );
}
}
class Invoice extends Base
{
public function __construct()
{
parent::__construct( "invoices" );
}
}
Base::set_api_key( "some secret key" );
$invoices = Invoice::get_all();