CodeIgniter Forums

Full Version: Can't Find Library/Helper/Class in CI
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

What is the preferred way of retrieving the passing the result of a call to a uri to a variable in PHP? I didn't stumble across something within CI, but I may have missed it. If not, I assume cURL?

El Forum

I don't understand your question...

If your wondering how to access the URL's data, you need to look into the URI class (

example URL (from CI documentation): index.php/user/search/name/joe/location/UK/gender/male
$array = $this->uri->uri_to_assoc(3); //3 represents the number of parts of the URL to obtain
$array looks like this after the call:
'name' => 'joe'
'location' => 'UK'
'gender' => 'male'

There are more methods of the uri class... so if this doesn't satisfy your need, i bet one of the others will

El Forum

I'm calling a function, like:

and get JSON back.

I'm trying to figure out if CI has an abstracted library to make the call or do I just use basic PHP curl_exec.

El Forum


Does that help? From my understanding... you have a php script on your server which your sending a HTTP request to for some data to be returned... so ... I'm not sure if CI has the code to do this... perhaps checking out the load library...

I would include the file, which would have a class declaration in it... (make sure the file doesn't allow direct access to it by users by checking to see if BASEPATH is defined) and then get an instance of the class and run the function... and return it

El Forum

As of PHP 5 JSON encode and decode is included in the PHP core!


El Forum

I'm not concerned about JSON encoding/decoding.
I'm talking about the HTTP call. This seems like something CI should have a helper for (for less code reasons):

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch)
// close cURL resource, and free up system resources

El Forum

why don't you write the helper file Wink

Sorry I couldn't help more... did you check the wiki ?