/** * A method that make a long url to short url. * * @param string $link * * @return string */ private function getShortUrl($link) { JLoader::register("ItpSocialButtonsPluginShortUrl", JPATH_PLUGINS . "/content/itpsocialbuttons/shorturl.php"); $options = array("login" => $this->params->get("login"), "api_key" => $this->params->get("apiKey"), "service" => $this->params->get("shortUrlService")); $shortLink = ""; try { $shortUrl = new ItpSocialButtonsPluginShortUrl($link, $options); $shortLink = $shortUrl->getUrl(); // Get original link if (!$shortLink) { $shortLink = $link; } } catch (Exception $e) { JLog::add($e->getMessage()); // Get original link if (!$shortLink) { $shortLink = $link; } } return $shortLink; }
/** * A method that make a long url to short url * * @param string $link * @param array $params * @return string */ private function getShortUrl($link){ JLoader::register("ItpSocialButtonsPluginShortUrl", dirname(__FILE__).DIRECTORY_SEPARATOR."shorturl.php"); $options = array( "login" => $this->params->get("login"), "api_key" => $this->params->get("apiKey"), "service" => $this->params->get("shortUrlService"), ); $shortLink = ""; try { $shortUrl = new ItpSocialButtonsPluginShortUrl($link, $options); $shortLink = $shortUrl->getUrl(); // Get original link if(!$shortLink) { $shortLink = $link; } } catch(Exception $e) { JLog::add($e->getMessage()); // Get original link if(!$shortLink) { $shortLink = $link; } } return $shortLink; }
/** * A method that make a long url to short url * * @param string $link * @param array $params * @return string */ private function getShortUrl($link, $params) { JLoader::register("ItpSocialButtonsPluginShortUrl", dirname(__FILE__) . DIRECTORY_SEPARATOR . "shorturl.php"); $options = array("login" => $params->get("login"), "apiKey" => $params->get("apiKey"), "service" => $params->get("shortUrlService")); $shortUrl = new ItpSocialButtonsPluginShortUrl($link, $options); $shortLink = $shortUrl->getUrl(); if (!$shortLink) { // Add logger JLog::addLogger(array('text_file' => 'error.php')); JLog::add($shortUrl->getError(), JLog::ERROR); // Get original link $shortLink = $link; } return $shortLink; }