Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 8 revisions

Category:Libraries | Category:Libraries::Community | Category:Libraries::Connectivity

Library to access the bit.ly API from CodeIgniter

[h3]Features[/h3]

  • 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

[h3]Download[/h3] [url]http://github.com/patrickpopowicz/bit.ly-Library-for-CodeIgniter[/url]

[h3]Usage[/h3] [code]$this->load->library('bitly', [ optional $params ]);[/code]

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.

[code]// Shorten request echo $this->bitly->shorten('http://www.example.com/');[/code]

Returns the bit.ly shortUrl, i.e. http://bit.ly/bldm16

[code]// Expand request echo $this->bitly->expand(array('http://bit.ly/bldm16'));[/code]

If there is only a single target, it will return the longUrl for that, otherwise it returns the entire response.

[code]// Make a call and force the entire reponse to be returned echo $this-bitly->shorten('http://www.example.com/', TRUE);[/code]

Returns full response in an array assuming the format is JSON, otherwise just a string for XML or TXT formats.

[code]// Get the full response after a simple call is made echo $this-bitly->shorten('http://www.example.com/', TRUE); // shortURL $response = ($this->bitly->response());[/code]

Returns full response in an array assuming the format is JSON, otherwise just a string for XML or TXT formats.

Clone this wiki locally