Welcome Guest, Not a member yet? Register   Sign In
How do I use the cURL library?
#1

[eluser]blend107[/eluser]
I've read and reread the user guide and some parts of the wiki but I've had no success installing and using content that didn't come with the core package of Code Igniter. I'm new to CI, truth be told, and I'm still not completely comfortable with OOP yet.

I downloaded the zip file and proceeded to put each file where it belonged. I wasn't sure what to do next, so I opened up the original index.php file and copy/pasted some lines from the wiki:
Code:
echo $this->curl->simple_get('http://example.com/');
Code:
$this->curl->simple_post('controller/method', array('foo'=>'bar'));
Needless to say, I got an error: Fatal error: Using $this when not in object context

I'm stumped. I don't think I can go any further if I don't at least get this right.
#2

[eluser]n0xie[/eluser]
Use it from within a controller not from the index.php
Code:
class Welcome extends Controller {

  function index()
  {
    $this->load->library('curl');
    echo $this->curl->simple_get('http://example.com');
  }
}




Theme © iAndrew 2016 - Forum software by © MyBB