Using the Open Weather Map, which is HTTP only through an HTTPS site, and DO NOT receive mixed content alerts

I checked this link here on SO: Working with HTTP content on HTTPS pages

I tried this regarding open protocols from here: http://benpowell.org/https-and-http-the-protocol-less-or-protocol-relative-urls/

But I only have one HTTP url call for openweathermap that does not serve its contents via HTTPS unless you pay them 500 / month. I can’t do it.

So, I need to find a way to enter HTTP content for OpenWeatherMap and not generate a “mixed content” error message in “any” browser.

Here's the API request for OWM: http://api.openweathermap.org/data/2.5/weather?lat=32.22&lon=-100.50&APPID=c6fdcf2d49a0bba3e14f310bd3d5cdc2

Any thoughts, anyone?

Thanks in advance.

+7
source share
3 answers

I came across this topic, trying to get my application hosted on a hero using the Open Weather Map API.

Put this in front of the address:

https://cors-anywhere.herokuapp.com/

so that url becomes

https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/forecast ? AppID = $ {api_key}

Check your application again and note that the openweather url is http again (as it was originally)! This solution worked for me, although the CORS solution cannot last forever.

+1
source

I managed to get api to download on my site that provides https with a little php.

Basically, I am twisting the http site and storing the results on my domain page, which is https, so it works great for me.

I wrote a little function to make me work

<?php #Defining the basic cURL function function curl($url) { $ch = curl_init(); // Initialising cURL #Setting cURL URL option with the $url variable passed into the function curl_setopt($ch, CURLOPT_URL, $url); #Setting cURL 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" ?> 

# Full fragment

  <?php // Defining the basic cURL function function curl($url) { $ch = curl_init(); // Initialising cURL curl_setopt($ch, CURLOPT_URL, $url); // Setting cURL URL option with the $url variable passed into the function curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL 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 
0
source

Since the .io forecast has changed to Dark Sky, and they do not allow CORS, which forces you to implement a server application, I was looking for another solution suitable for a small front-end project.

I found apixu.com , which seems to be much better suited for a simple purpose such as mine: the FreeCodeCamp project.

They provide both HTTP and https calls. You get 5,000 calls per month for free.

0
source

All Articles