Skip to content

Instantly share code, notes, and snippets.

@esseguin
Created August 10, 2012 01:50
Show Gist options
  • Save esseguin/3310252 to your computer and use it in GitHub Desktop.
Save esseguin/3310252 to your computer and use it in GitHub Desktop.
<?php
require_once("Bitly.php");
$bitly = new Bitly("MY_PUBLIC_KEY", "MY_PRIVATE_KEY", "MY_API_KEY", "MY_LOGIN");
$response = $bitly->getShortenedUrl("http://mashape.com/docs/consume/php");
echo $response->statusCode; // should be "200"
echo $response->headers; // A string showing the headers of the response
if ($response->statusCode == "200") {
// $response->body will be a stdClass representing the parsed response
echo "Shortened URL: " . $response->body->shortenedUrl;
} else {
// $response->rawBody will be a string representing the unparsed response
echo "Problem with request. Response: " . $response->rawBody;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment