1

i am trying to call & get another url data.So is trying to create new instance of http class as follows -

jimport('joomla.http.http');
jimport('joomla.http.transport.curl');
$options = array();
$transport =  new JHttpTransportCurl($options); 
// Create a 'curl' transport.
$http = new JHttp($options, $transport);
$response = $http->get('http://api.example.com/shoes');

but it's not working as somewhere wrong in line 4. Please save my time hoping this is the right way to make call to another API url.

9
  • Something wrong? Do you have any errors? Jun 10, 2014 at 6:53
  • i set error reporting but no error shown but blank screen. by debug what i see is debug hangs in line 4, it's look like it can't create a new instance of jhttptransportcurl.question is how do i make call to external url using http class.
    – dev-m
    Jun 10, 2014 at 12:38
  • Well honestly I do not know why it is stacking there, but you can try to use JHttpFactory to get Http: JHttpFactory::getHttp($options, 'curl') Jun 10, 2014 at 13:01
  • i am using joomla 2.5 and this class is where?
    – dev-m
    Jun 10, 2014 at 13:03
  • /libraries/joomla/http/factory.php Jun 10, 2014 at 13:09

1 Answer 1

3

Just to have a valid answer.

The problem was in $options - it is an array, but JHttpTransportCurl constructor require JRegistry instance. So

$options = array();

should be changed to

$options = new JRegistry();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.