Embedding charts from a remote server

 Now that iframes are actively surpressed by both Chrome and Firefox (but not Safari) I am looking for a cross browser alternative. I have no idea what IE does!

My emonCMS server is happily running on my home server. However my main site is hosted externally.

This page http://metphoto.net/metc/power.php contains a simple iframe line which displays the remote chart perfectly well using Safari. However using Chrome I get my custom 404 page in place of the graph.  Under Firefox I get the same 404 page displayed, albeit very poorly rendered.

The PHP functions 'require' or 'include' don't appear to work. Although they may do so on some hosting providors. 

From http://www.php.net/manual/en/features.remote-files.php

"As long as allow_url_fopen is enabled in php.ini, you can use HTTP and FTP URLs with most of the functions that take a filename as a parameter. In addition, URLs can be used with the include(), include_once(), require() and require_once() statements (since PHP 5.2.0, allow_url_include must be enabled for these)..."

Maybe allow_url_fopen is disbaled on my provider; 1and1.

I have also tried the HTML "object" function, but that appears to work the same as the iframe, i.e. it will not work on Firefox or Chrome.

I have seen some suggestions that jQuery may work.

Any ideas?

Mark

MetPhoto's picture

Re: Embedding charts from a remote server

 Morning

I have just found the emoncms_extras / Visualisations code.  This may well do what I want, however I am stuck on line 50 of vis01.php

url: 'YOUR DIRECTORY PATH/api/getfeed',  What exactly do I put in here?

I have tried a few varations of the API url shown on my emoncms/API page but with no luck so far.

(just to be clear I have also edited lines 14,15,31 and 34)

Mark

stinor's picture

Re: Embedding charts from a remote server

I don't know if this is where you're after but I use the following php-script to get data from an external server. When you type in www.yoursite.com/file.php?url=www.othersite.com it displays the othersite.com

 

<?php

$val = $_GET['url'];

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "$val");
curl_setopt($ch, CURLOPT_HEADER, 0);

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

?>

 

TrystanLea's picture

Re: Embedding charts from a remote server

Metphoto, I had a look at the source of your webpage with the embedded graph and see that the reason its coming up with a 404 is that the address is missing a forward slash "http:/metphoto... should be http://metphoto. It should work after that

 

MetPhoto's picture

Re: Embedding charts from a remote server

 Wow!, that is a surprise.  Many thanks for spotting that.  I am bright red with embarrassment.  Here I was going on about iframes when it was a typo all along.

The very strange thing was that the page worked perfectly in Safari, but not in IE, Chrome or Firefox!

Again thanks for the help.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.