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.

  • Something wrong? Do you have any errors? – Dmitry Rekun Jun 10 '14 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 '14 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') – Dmitry Rekun Jun 10 '14 at 13:01
  • i am using joomla 2.5 and this class is where? – dev-m Jun 10 '14 at 13:03
  • /libraries/joomla/http/factory.php – Dmitry Rekun Jun 10 '14 at 13:09
2

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, privacy policy and cookie policy

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