Jump to content

from api to php


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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...