使用仅通过HTTPS网站的HTTP的开放天气地图,而不是混合内容警告

Pet*_*ude 7 ssl https http

我在SO上查看了此链接:处理HTTPS页面中的HTTP内容

我从这里开始试用这个开放式协议:http://benpowell.org/https-and-http-the-protocol-less-or-protocol-relative-urls/

但我只有一个调用openoutmap的HTTP网址,它不会通过HTTPS提供内容,除非你支付500/mo.不能这样做.

因此,我需要找到一种方法来为OpenWeatherMap引入HTTP内容,而不是在"任何"浏览器上生成"混合内容"错误消息.

这是OWM的API调用:http://api.openweathermap.org/data/2.5/weather la = 32.22 &lon = 100.50&APPID = c6fdcf2d49a0bba3e14f310bd3d5cdc2

任何想法,任何人?

提前致谢.

小智 0

我能够在我的网站上加载 api,使用一点 php 强制执行 https。

基本上,我卷曲 http 站点并将结果存储在我的域的 https 页面上,因此它非常适合我。

我写了一个小函数来为我完成这项工作

 <?php
#Defining the basic cURL function
    function curl($url) {
    $ch = curl_init();  // Initialising cURL
#Setting cURL's URL option with the $url variable passed into the function
    curl_setopt($ch, CURLOPT_URL, $url);
#Setting cURL's option to return the webpage data   
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 
#Executing the cURL request and assigning the returned data to the $data variable
    $data = curl_exec($ch); 
#Closing cURL 
    curl_close($ch); 
#Returning the data from the function  
    return $data;  
 }
     echo $scraped_website = curl("http://www.example.com");

#I use http://api.openweathermap.org/data//2.5/weather?q=Saint+Louis%2C+MO&units=imperial&lang=nl&APPID=b923732c614593659457d8f33fb0d6fd&cnt=6 instead of "http://www.example.com"

?>
Run Code Online (Sandbox Code Playgroud)

#完整片段

     <?php
     // Defining the basic cURL function
    function curl($url) {
    $ch = curl_init();  // Initialising cURL
    curl_setopt($ch, CURLOPT_URL, $url);    // Setting cURL's URL option with the $url variable passed into the function
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL's option to return the webpage data
    $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
    curl_close($ch);    // Closing cURL
    return $data;   // Returning the data from the function
      }
     echo $scraped_website = curl("http://www.example.com");
     ?>



enter code here
Run Code Online (Sandbox Code Playgroud)