Example #1
0
 public function exec()
 {
     $uri = \Kiki\TinyUrl::lookup62($this->objectId);
     if ($this->content = $uri) {
         $this->status = 301;
     }
 }
Example #2
0
 /**
  * Retrieves a tinyURL for a full URL. Tries a lookup first and creates a
  * new tinyURL upon failure.
  *
  * @param string $url URL of the resource
  *
  * @return string tinyURL for the resource
  */
 public static function get($url)
 {
     $db = Core::getDb();
     $q = $db->buildQuery("select id from tinyurl where url='%s'", $url);
     $id = $db->getSingleValue($q);
     if (!$id) {
         $id = TinyUrl::insert($url);
     }
     $host = Config::$tinyHost ? Config::$tinyHost : $_SERVER['SERVER_NAME'];
     // TODO: support HTTPS
     return sprintf("http://%s/%03s", $host, Base62::encode($id));
 }
Example #3
0
 public function postEvent(&$event)
 {
     $tinyUrl = \Kiki\TinyUrl::get($event->url());
     $msg = sprintf("%s %s %s", $event->title(), $tinyUrl, $event->hashtags());
     $result = $this->post($event->objectId(), $msg);
     return $result;
 }