3

セキュリティで保護されたサイトにグラフを画像として読み込もうとしています。https を介した Google Chart 画像の例は次のとおりです。

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

問題は、リンクを直接クリックしてこのような画像を読み込むことはできますが、ページに画像として含めることができないことです。ロードされないだけです。

これをバイパスする方法について何か考えはありますか? または、一般的にPHPを使用するソリューションですか?

4

3 に答える 3

8

GoogleがついにAPIを更新してHTTPSを許可したようです。ホスト名をchart.googleapis.comに切り替えるだけで、ベースURLがhttps://chart.googleapis.com/chartのようになり、正常に機能します。楽しみ!

于 2011-01-19T19:47:48.520 に答える
5

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
?>
于 2010-03-20T06:39:12.190 に答える
4

Referrer: ヘッダーが設定されているグラフの https リクエストを Google がブロックしているようです。

[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
于 2010-03-20T06:33:39.223 に答える