PHP code example of fastwhale / wordpress-php-sdk
1. Go to this page and download the library: Download fastwhale/wordpress-php-sdk 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/ */
fastwhale / wordpress-php-sdk example snippets
composer
Fastwhale\WordPress\WordPressServiceProvider::class,
'WP' => Fastwhale\WordPress\WordPressFacade::class,
php artisan vendor:publish --provider="Fastwhale\WordPress\WordPressServiceProvider"
use Fastwhale\WordPress\WordPressFacade as WordPress;
$token = WordPress::login($request->get('email'), $request->get('password'));
// {'token': '...'}
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::user()->list();
$result = WordPress::user()->create($data);
$user = WordPress::user()->get($id);
$result = WordPress::user()->update($id, $data);
$result = WordPress::user()->delete($id);
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::post()->list();
$result = WordPress::post()->create($data);
$user = WordPress::post()->get($id);
$result = WordPress::post()->update($id, $data);
$result = WordPress::post()->delete($id);
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::customPost('custom_post_type')->list();
$result = WordPress::customPost('custom_post_type')->create($data);
$user = WordPress::customPost('custom_post_type')->get($id);
$result = WordPress::customPost('custom_post_type')->update($id, $data);
$result = WordPress::customPost('custom_post_type')->delete($id);
use Fastwhale\WordPress\WordPressFacade as WordPress;
$users = WordPress::tag()->list();
$result = WordPress::tag()->create($data);
$user = WordPress::tag()->get($id);
$result = WordPress::tag()->update($id, $data);
$result = WordPress::tag()->delete($id);
$data = [
'title' => 'title',
'parent' => 0,
'slug' => Str::slug('title', '-'),
'content' => 'content',
];
$post = WordPress::post()->create($data);
// {'id': ...}