1

I have a problem with the REST API in Codeigniter. When i put the url in Firefox I get the desired response, so i know the url is correct. Using the code below, I get a timeout. I have no idea what is causing this. Any help would be greatly appreciated.

$json = file_get_contents('http://localhost/q3n/index.php/api/action_count/status/2');

print_r(json_decode($json));
RandomUsername
  • 364
  • 1
  • 5
  • 13
  • Read here:http://stackoverflow.com/questions/8423404/php-file-get-contents-does-not-work-on-localhost – Yan Berk Mar 25 '13 at 20:50

1 Answers1

1

If you had curl library in your codeigniter you can sue that also to do this operation like below. If you don't have curl library you can find curl library for codeigniter in this link and you can find small tutorial also.

$url_path = "http://localhost/q3n/index.php/api/action_count/status/2";

 $res = $this->curl->simple_get($url_path);

 $result = json_decode($res, true);
Venkata Krishna
  • 4,287
  • 6
  • 30
  • 53