Пример #1
0
 /**
  * @param $code
  * @return Token
  */
 public function getAccessToken($code = null, $back = null)
 {
     if (null !== $code) {
         $this->code = $code;
     }
     $redirectUri = $this->redirectUri;
     if ($back) {
         $redirectUri .= '/back/' . base64_encode($back);
     }
     if (null === $this->token) {
         var_dump('code:', $this->code);
         $url = 'https://oauth.vk.com/access_token' . '?client_id=' . $this->appId . '&client_secret=' . $this->appSecret . '&v=' . self::API_VERSION . '&code=' . $this->code . '&redirect_uri=' . $redirectUri;
         //. '&redirect_uri=' . $this->redirectUri;
         $raw = \Yaoi\Http\Client::getInstance('vk')->fetch($url);
         var_dump('raw:', $url, $raw);
         $this->token = json_decode($raw);
     }
     var_dump('token:', $this->token);
     return $this->token;
 }
Пример #2
0
 private function getPerlTablesUrlList()
 {
     $client = new Client();
     $list = array();
     $page = $client->fetch('http://cpansearch.perl.org/src/SBURKE/Text-Unidecode-' . self::LIB_VERSION . '/lib/Text/Unidecode/');
     foreach (StringParser::create($page)->innerAll('.pm">', '</a>') as $xXXpm) {
         $list[] = 'http://cpansearch.perl.org/src/SBURKE/Text-Unidecode-' . self::LIB_VERSION . '/lib/Text/Unidecode/' . $xXXpm;
     }
     return $list;
 }
Пример #3
0
use Yaoi\Database;
use Yaoi\Http;
use Yaoi\Migration;
use Yaoi\Mock;
use Yaoi\Storage;
date_default_timezone_set('Asia/Bangkok');
//Storage::getInstance('mock')->deleteAll();
Client::register(function () {
    $settings = new Settings();
    $settings->username = '******';
    $settings->password = '******';
    return $settings;
});
Http\Client::register(function () {
    $client = new Http\Client();
    $client->mock(new Mock(Storage::getInstance('mock')));
    return $client;
});
Storage::register(function () {
    $settings = new Storage\Settings();
    $settings->driverClassName = Storage\Driver\SerializedFile::className();
    $settings->path = __DIR__ . '/resources/mock4.serialized';
    return $settings;
}, 'mock');
Database::register('mysqli://root:@localhost/wakabot?timezone=Asia/Jakarta');
/*
Database::register(function(){
    $settings = new Database\Settings();
    $settings->driverClassName = Database\Driver\Sqlite::className();
    $settings->path = __DIR__ . '/resources/db.sqlite';
Пример #4
0
 private function http()
 {
     if (null === $this->resourceHttp) {
         $this->resourceHttp = \Yaoi\Http\Client::getInstance($this->settings->httpClient);
     }
     return $this->resourceHttp;
 }
Пример #5
0
 public function deleteAll()
 {
     $this->http->reset()->post = array('deleteAll');
     $this->http->fetch($this->dsnUrl);
 }