-
Notifications
You must be signed in to change notification settings - Fork 7.6k
bit.ly Library
Category:Libraries | Category:Libraries::Community | Category:Libraries::Connectivity
Library to access the bit.ly API from CodeIgniter
- Processes all API v3 methods
- Autoloads config settings and supports config override through the Initialize method
- Simple, short output for default JSON and TXT requests to the API
- Full response output for XML requests
- Flag for full response on any request
http://github.com/patrickpopowicz/codeigniter-bitly
$this->load->library('bitly', [ optional $params ]);
All methods will return the API response on a successful request. Any call that contains invalid or malformed parameters will return FALSE without calling the API, which would return an error in any case. All methods have an option $verbose flag, and if set to TRUE, the entire API response is returned.
// Shorten request
echo $this->bitly->shorten('http://www.example.com/');
Returns the bit.ly shortUrl, i.e. http://bit.ly/bldm16
// Expand request
echo $this->bitly->expand(array('http://bit.ly/bldm16'));
If there is only a single target, it will return the longUrl for that, otherwise it returns the entire response.
// Make a call and force the entire reponse to be returned
echo $this->bitly->shorten('http://www.example.com/', TRUE);
Returns full response in an array assuming the format is JSON, otherwise just a string for XML or TXT formats.
// Get the full response after a simple call is made
echo $this->bitly->shorten('http://www.example.com/', TRUE); // shortURL
$response = ($this->bitly->response());
Returns full response in an array assuming the format is JSON, otherwise just a string for XML or TXT formats.