• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't Find Library/Helper/Class in CI

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?

I don't understand your question...

If your wondering how to access the URL's data, you need to look into the URI class (http://ellislab.com/codeigniter/user-gui...s/uri.html)

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

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.


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

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


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, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch)
// close cURL resource, and free up system resources

why don't you write the helper file Wink

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.