Hi,
I am trying to display the cacti graph in my page using php and curl but it seems its not showing the image or if we use direct img source as the url then i will display graph image only when we logged in the cacti otherwise it won't display. I am using the following code, could you please check if anything wrong
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, '<url>/cacti/index.php');
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'action=login&login_username=admin&login_password=admin');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$store = curl_exec ($ch);
curl_setopt($ch, CURLOPT_URL, '<url>/cacti/graph_image.php?local_graph_id=740&rra_id=0');
$content = curl_exec ($ch);
if(curl_exec($ch) === false)
{
echo 'Curl error: ' . curl_error($ch);
}
else
{
header('Content-Type: image/png');
readfile("<url>/cacti/graph_image.php?local_graph_id=740&rra_id=0");
exit;
}
//Close CURL
How to display cacti graph in a page using php and curl
Moderators: Developers, Moderators
Who is online
Users browsing this forum: No registered users and 2 guests