PHP code example of monitorbacklinks / yii2-wordpress

1. Go to this page and download the library: Download monitorbacklinks/yii2-wordpress 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/ */

    

monitorbacklinks / yii2-wordpress example snippets


    'components' => [
        ...
        'blog' => [
            'class' => '\monitorbacklinks\yii2wp\Wordpress',
            'endpoint' => 'http://example.com/xmlrpc.php',
            'username' => 'demo',
            'password' => 'demo'
        ]
        ...
    ]

    $blogPosts = Yii::$app->blog->getPosts([
        'post_status' => 'publish',
        'number' => 10
    ], ['guid', 'post_title', 'post_content']);

    $postID = Yii::$app->blog->newPost('New post', 'Hello world!');

    // The user profile will be fetched from cache if available.
    // If not, the query will be made against XML-RPC API and cached for use next time.
    $profile = Yii::$app->blog->cache(function (Wordpress $blog) {
        return $blog->getProfile();
    });

    $blogPosts = Yii::$app->blog->cache(function (Wordpress $blog) {

        // ... queries that use query cache ...

        return $blog->noCache(function (Wordpress $blog) {
            // this query will not use query cache
            return $blog->getPosts();
        });
    });

    'components' => [
        ...
        'log' => [
            'targets' => [
                'file' => [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error'],
                    'categories' => ['monitorbacklinks\yii2wp\Wordpress::*'],
                ],
            ],
        ],
        ...
    ]
 php composer.phar