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

When i develop some project, i need to have a simple way to call another controller, or even an external resource (ex. api from google). I create a simple cURL class to do that. This is the (almost) stable version of that, this enough for my needs. I'll take it to higher level, as soon as i had a long holiday from my work.

For now, enjoy!

[code] // Simple way to use this library // In any controller, put this line... ... $this->load->library('proxy'); $this->proxy->site('http://codeigniter.com',TRUE); ...

// Above example will give you rendered page of CodeIgniter site, if you didn't want // to render it directly, or it was a json which you want to save to var, simply do this... ... $this->load->library('proxy'); $json_var = $this->proxy->site('http://ip2country.sourceforge.net/ip2c.php?ip='.$ip.'&format=JSON'); ...

// To call your controller (maybe in some situation, you need it instead use redirect() function) ... $this->load->library('proxy'); $this->proxy->controller('your_target_controller_name/target_function/some_id'); ... [/code]

[b]MORE FEATURES(All old feature still there):[/b]

  1. Get Full HTTP Header.
  2. Set Proxy Call.
  3. Set Delay HTTP Call.
  4. Set user agent.
  5. Internal cache (using gzip).
  6. Persistent call (processing redirect, either from header or meta)
  7. NO NEED FANCY CURL STUFF DEPEDENCIES! PURE PHP.
  8. Cookie support.
  9. Log and error flag. [code] $this->load->library('proxy'); //Set proxy call $this->proxy->set_proxy('proxy_host',80,'username','password'); $this->proxy->site('twitter.com',TRUE); //Get rendered HTTP header, for use it as variable, // put FALSE on second passed param or simple let it blank $this->proxy->head('codeigniter.com',TRUE); //Set user agent and delay $this->proxy->set_delay(5); $this->proxy->set_useragent($this->session->userdata('user_agent')); $this->proxy->site('twitter.com',TRUE); [/code] ============================================================================ cleaning (some debug crap) and fixing structure alse adding ReadMe.txt ============================================================================ Version History File:ProxyLibrary_v1.0.2.zip [LATEST] File:ProxyLibrary_v1.0.1.zip File:ProxyLibrary_v1.zip ============================================================================ Hope you find this object useful.

Category:Contributions::Libraries::Networking

Clone this wiki locally