Created
August 10, 2012 01:50
-
-
Save esseguin/3310252 to your computer and use it in GitHub Desktop.
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 | |
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