public function __construct() { parent::__construct(); $this->shortner = Url_Shortner::factory(); }
public static function shorten_url($longUrl) { $options = array('longUrl' => $longUrl); $bitly = Url_Shortner::factory()->add_options($options); $results = $bilty->execute(); if (is_array($longUrl)) { $res = array(); foreach ($results->results as $key => $url) { $res[$key] = $url->shortUrl; } return $res; } return $results->results->{$longUrl}->shortUrl; }