Jump to content

from api to php


tetah31

Recommended Posts

good evening,

i'm trying to get info from openweathermap to my own site i only know html - css and a little php.

php say that the first line <?php $url = .... ?> have a error i d'ont undestand the problem.

here is my code that i use for getting this information :

	<aside>
	
		<?php $url = https://api.openweathermap.org/data/2.5/find?q=Veurne&units=metric&type=accurate&mode=xml&APPID=my own id; $getweather = simplexml_load_file ($url); ?>
		<?php $gethumidity = $getweather->list->item->humidity('value'); ?>
		<?php $gettemp = $getweather->list->item->temperature('value'); ?>
		<?php $feelslike = $getweather->list->item->feels_like('value'); ?>
		<?php $speed = $getweather->list->item->speed('value'); ?>
		<?php $direction = $getweather->list->item->direction('code'); ?>
		
		<h3>info</h3>
		<h4>weather</h4>
		<ul>
			<li>Temperature: <?php echo($gettemp); ?> &deg;C</li>
			<li>feels like: <?php echo($feelslike); ?> &deg;C</li>
			<li>wind speed: <?php echo($speed); ?> m/s</li>
			<li>wind direction: <?php echo($direction); ?></li>
			<li>humidity: <?php echo($gethumidity); ?> %</li>
		</ul>
	</aside>

 

Link to comment
Share on other sites

I can haphazard a guess, that you haven't put quotes around your string.

You also may want to directly include the error, because an "error" could possible be your internet being offline.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...