Google Charts Over HTTPS

I am trying to upload diagrams as images on a secure site. An example of a Google Chart image over https would be the following:

http://www.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld

The problem is that although you can upload such an image simply by clicking on the link, you cannot include it as an image on your page. It just does not load.

Any idea on how to get around this? Or a solution that usually uses PHP?

+3
source share
3 answers

Google does not support charts on HTTPS ...

I had the same problem.

http://groups.google.com/group/google-chart-api/browse_thread/thread/95c463d88cf3cfe4

PHP .net - HTTP- Google HTTPS .

PHP-, ...

<?php
    // PHP Proxy
    // Loads a XML from any location. Used with Flash/Flex apps to bypass security restrictions
    // Author: Paulo Fierro
    // January 29, 2006
    // usage: proxy.php?url=http://mysite.com/myxml.xml

    $session = curl_init($_GET['url']);                    // Open the Curl session
    curl_setopt($session, CURLOPT_HEADER, false);          // Don't return HTTP headers
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);   // Do return the contents of the call
    $xml = curl_exec($session);                            // Make the call
    header("Content-Type: text/xml");                  // Set the content type appropriately
    echo $xml;        // Spit out the xml
    curl_close($session); // And close the session
?>
+5

, Google API, HTTPS. , , chart.googleapis.com, URL - https://chart.googleapis.com/chart, . !

+8

It looks like Google is blocking https requests for charts with a set of Referrer headers:

[tla ~]$ curl 'http://www.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld' 2>/dev/null | file -
/dev/stdin: PNG image, 200 x 125, 8-bit/color RGB, non-interlaced
[tla ~]$ curl 'https://www.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld' 2>/dev/null | file -
/dev/stdin: PNG image, 200 x 125, 8-bit/color RGB, non-interlaced
[tla ~]$ curl -H 'Referer: http://stackoverflow.com' 'http://www.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld' 2>/dev/null | file -
/dev/stdin: PNG image, 200 x 125, 8-bit/color RGB, non-interlaced
[tla ~]$ curl -H 'Referer: http://stackoverflow.com' 'https://www.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld' 2>/dev/null | file -
/dev/stdin: ASCII HTML document text, with very long lines
+4
source

Source: https://habr.com/ru/post/1737785/


All Articles