Use curl in custom module Magento ver 1.9.x
In /var/www/html/magento193/app/design/frontend/base/default/template/reviewrating/rightsidebar.phtml
$url = "http://mywebsite.com/api/extentionReviews?key=s4o3mbe8key9";
$getJson = $this->getDataFromApi( $url );
$ApiData = Mage::helper('core')->jsonDecode( $getJson );
print_r( $getJson );
In /var/www/html/magento193/app/code/local/Custommodule/ReviewRating/Block/Rightsidebar.php
public function getDataFromApi( $url )
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return ($httpcode>=200 && $httpcode<300) ? $data : false;
}
In /var/www/html/magento193/app/design/frontend/base/default/layout/reviewrating.xml
<reference name="right">
<block type="reviewrating/rightsidebar" name="reviewrating_rightsidebar" beofre="-" template="reviewrating/rightsidebar.phtml" />
</reference>
Output : I am still getting data in json format. i want it to be in array.
{ "success":true,
"error":false,
"error_code":"",
"message":"Successfully listed."
..........
}