Ejemplo n.º 1
0
 /**
  * @return \stdClass
  */
 public function getBlogInfo() : \stdClass
 {
     if ($this->blogInfo === null) {
         if ($this->redisClient !== null) {
             $userInfo = $this->redisClient->get('userInfo');
             if ($userInfo) {
                 $this->blogInfo = json_decode($userInfo, true);
                 return $this->blogInfo;
             }
         }
         try {
             $this->blogInfo = json_encode($this->thumblrClient->getUserInfo()->user->blogs[0], JSON_PRETTY_PRINT);
             if ($this->redisClient !== null) {
                 $this->redisClient->set('userInfo', $this->blogInfo);
                 $this->redisClient->expireat('userInfo', time() + 3600);
             }
         } catch (RequestException $exception) {
             /*header("content-type: text/plain");
             
             
             
                             echo $exception->getMessage().PHP_EOL;
                             echo $exception->getCode().PHP_EOL;
                             echo $exception->getTraceAsString().PHP_EOL;
                             print_r($this->thumblrClient);
                             die();*/
         }
     }
     return json_decode($this->blogInfo, true);
 }
Ejemplo n.º 2
0
<?php

ini_set('display_errors', 1);
include __DIR__ . '/tumblr/vendor/autoload.php';
session_start();
use Tumblr\API\Client as TClient;
$consumerKey = $_SESSION['client_id'];
$consumerSecret = $_SESSION['client_secret'];
$token = $_SESSION['token'];
$tokenSecret = $_SESSION['secret'];
$client = new TClient($consumerKey, $consumerSecret);
$client->setToken($_SESSION['token'], $_SESSION['secret']);
session_start();
print_r($client->getUserInfo());