Skip to content

Instantly share code, notes, and snippets.

@AngeloR
Created March 8, 2011 18:09
Show Gist options
  • Save AngeloR/860674 to your computer and use it in GitHub Desktop.
Save AngeloR/860674 to your computer and use it in GitHub Desktop.
Url Shortening with Goo.gl
<?php
$longUrl = 'http://facebook.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, 'http://goo.gl/api/shorten');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'security_token=null&url='.$longUrl);
$content = curl_exec($ch);
curl_close($ch);
echo json_encode($content);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment