Created
March 8, 2011 18:09
-
-
Save AngeloR/860674 to your computer and use it in GitHub Desktop.
Url Shortening with Goo.gl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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