Skip to content

Instantly share code, notes, and snippets.

@Uriel29
Last active August 29, 2015 14:06
Show Gist options
  • Save Uriel29/685cef918e06b8e79d93 to your computer and use it in GitHub Desktop.
Save Uriel29/685cef918e06b8e79d93 to your computer and use it in GitHub Desktop.
Encurtar URL do Joomla com o encurtador Migre.me! Colocar isso no content do Joomla. Via override do article. Funciona no content do Seblod (sem qualquer edição)
<?php
/**
* Acessa a API do migre.me e gera uma URL encurtada
* @param $url URL a ser encurtada
* @return String URL encurtada ou informações do erro
*/
function gera_url_encurtada($url){
$url = urlencode($url);
$xml = simplexml_load_file("http://migre.me/api.xml?url=$url");
if($xml->error != 0){
return $xml->errormessage;
}
else{
return $xml->migre;
}
}
$urlabsoluta = JURI::current(); //pega a URL do artigo current (ao vivo) url completa.
$url_encurtada_2 = gera_url_encurtada("$urlabsoluta");
?>
<input type="text" value="<?php echo $url_encurtada_2; ?>" /> <! mostra URL dentro de um campo de texto. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment