PHP code example of rafael.paulino / wpapi

1. Go to this page and download the library: Download rafael.paulino/wpapi 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/ */

    

rafael.paulino / wpapi example snippets



ordPress\WordPressFacade;

$client_id = '';
$redirect_url = 'http://localhost:81/wpapi/';
$secret = '';

$facade = new WordPressFacade($client_id, $redirect_url, $secret);
$retorno = $facade->getToken();

if ($retorno['url'] !== "") {
    echo '<a href="' . $retorno['url'] . '">Login</a>';
} else {
    
    $user = $facade->getUserInfo();
    echo '<h1>User and Site Info:</h1><pre>';
    var_dump($user);
    echo '</pre><hr>';

    $site = $facade->getSiteInfo(15303042);
    echo '<h1>Especific Site Info:</h1><pre>';
    var_dump($site);
    echo '</pre><hr>';

    $post = $facade->postAdd(
        15303042,
        'titulo',
        'conteudo',
        'resumo',
        'http://visitsetubal.com.pt/wp-content/uploads/2013/03/Praia_Albarquel_02.jpg'
    );
    echo '<h1>Add Post:</h1><pre>';
    var_dump($post);
    echo '</pre><hr>';

    $p = $facade->postInfo(
        15303042,
        139
    );
    echo '<h1>Post Info:</h1><pre>';
    var_dump($p);
    echo '</pre><hr>';


    $post = $facade->postEdit(
        15303042,
        147,
        'titulo 123',
        'conteudo 456',
        'resumo 8910',
        'https://www.tribunapr.com.br/cacadores-de-noticias/wp-content/uploads/sites/2/2018/03/WEB-PREDIO-10-1024x683.jpg'
    );
    echo '<h1>Edit Post:</h1><pre>';
    var_dump($post);
    echo '</pre><hr>';


    $del = $facade->postDel(
        15303042,
        147
    );
    echo '<h1>Del Post:</h1><pre>';
    var_dump($del);
    echo '</pre><hr>';
    

}