swt*_*t83 3 php google-visualization
我正在尝试将图表作为图像加载到安全的站点中.通过https的Google Chart图像示例如下:
http://www.google.com/chart?cht=lc&chs=200x125&chd=s:helloWorld
问题是,虽然您可以通过直接单击链接来加载这样的图像,但不能将其作为图像包含在页面中.它只是不会加载.
有关如何绕过这个的任何想法?或者解决方案一般使用PHP?
小智 8
看起来谷歌最终更新了他们的API以允许HTTPS.您需要做的就是将主机名切换到chart.googleapis.com,以便基本URL类似于https://chart.googleapis.com/chart,它可以正常工作.请享用!
Google不支持基于HTTPS的图表...
我有同样的问题.
http://groups.google.com/group/google-chart-api/browse_thread/thread/95c463d88cf3cfe4
但是,您可以使用PHP或.net创建代理页面,以通过HTTPS连接过滤您的Google HTTP链接以解决此类问题.
这是我用过的一个简单的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
?>
Run Code Online (Sandbox Code Playgroud)