Skip to content

Instantly share code, notes, and snippets.

@Uriel29
Last active August 29, 2015 14:06
Show Gist options
  • Save Uriel29/6324e55a26a682fdbb6d to your computer and use it in GitHub Desktop.
Save Uriel29/6324e55a26a682fdbb6d to your computer and use it in GitHub Desktop.
Encurtar URL pelo google. Pegue sua KEY aqui > https://code.google.com/apis/console/. Coloque esse código no override (article) do seu Joomla. No Seblod basta colar no content
<?php
$urlabsoluta = JURI::current(); //pega a URL do artigo current (ao vivo)
$url = 'https://www.googleapis.com/urlshortener/v1/url';
$data['longUrl'] = "$urlabsoluta";
$data['key'] = 'Sua KEY'; //Sua Key dada pelo Google!
$data = json_encode($data);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$data = curl_exec($curl);
curl_close($curl);
$data = json_decode($data);
?>
<input type="text" value="<?php echo $data -> id; ?>" /> <! 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