PHP code example of buyakova / yii2-yandex-webmaster

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

    

buyakova / yii2-yandex-webmaster example snippets


public function addWebmaster($model)
{
    $token = Yii::$app->params['yandex_webmaster_token'];
    $url = 'http://test.website.com';
    
    $webmaster = new YandexWebmaster($token);
    $host_id = $webmaster->addWebsite($url);
    $uin = $webmaster->getVerify($host_id);
    
    $model->yandex_webmaster_id = $host_id;
    $model->yandex_webmaster_uin = $uin;
    if ($model->save()) {
        return $webmaster->sendVerify($host_id);
    }
    return false;
}