Exemplo n.º 1
0
 private function getSocialNetwork()
 {
     $site = false;
     switch (\Yii::$app->session->get('USER')->site) {
         case User::SITE_VK:
             $site = new VK();
             VK::setConfig(\yii::$app->params['vkAPI']);
             break;
         case User::SITE_OK:
             $site = new OK();
             OK::setConfig(\yii::$app->params['okAPI']);
             break;
         case User::SITE_FB:
             $site = new FB();
             FB::setConfig(\yii::$app->params['fbAPI']);
             break;
     }
     if (!$site) {
         \yii::$app->response->redirect('/auth');
     }
     return $site;
 }
Exemplo n.º 2
0
<?php

use frontend\modules\socials\FB;
use frontend\modules\socials\OK;
use frontend\modules\socials\VK;
?>
<a class="btn btn-primary" href="<?php 
echo VK::getURLForAuth(\yii::$app->params['vkAPI']);
?>
">Войти через ВК</a>
<a class="btn btn-primary" href="<?php 
echo OK::getURLForAuth(\yii::$app->params['okAPI']);
?>
">Войти через OK</a>
<a class="btn btn-primary" href="<?php 
echo FB::getURLForAuth(\yii::$app->params['fbAPI']);
?>
">Войти через FB</a>