130 likes | 246 Views
This assignment focuses on developing a service-oriented application that integrates various external services. The project aims to include multiple components, such as a weather display, news feed, and a mapping feature, depending on the group size. Each group will create at least three to four components, alongside documentation files and a configuration file. The application leverages technologies like PHP, XML, and JavaScript, utilizing RSS feeds for weather and news from sources like Yahoo and BBC News. Participants will also need to register their group for project tracking.
E N D
Appreciating the context … or What are we trying to do? … building an application using external services … or a “service oriented” application
Minimum Requirements / Deliverables (relaxed version) • 3 / 4 components depending on group size • weather component • news component • a map component • one other (individual) • 1 configuration file • 2 documentation file (xml – structure & schema yet to be published) • using any or all of : php, xhtml, xml, kml, rss, css, javascript, yahoo-pipes,csv
How? crunch rss feeds Source : yahoo weather rss feeds Bristol : http://weather.yahooapis.com/forecastrss?p=UKXX0025&u=f Bordeaux : http://weather.yahooapis.com/forecastrss?p=FRIF0476&u=f (or use yahoo-pipes) BRISTOL / BORDEAUX example
example using php & simplexml() require_once('utility_lib.php'); $url = 'http://weather.yahooapis.com/forecastrss?p=UKXX0025&u=f'; $rss = @simplexml_load_string(get_file($url)); if($rss) { foreach($rss->channel->item as $item) { echo $item->title.'<br/>'; $ns = $item->children('http://xml.weather.yahoo.com/ns/rss/1.0'); echo (string) $ns->condition->attributes()->text.'<br/>'; echo (string) $ns->condition->attributes()->temp.'°F<br/>'; echo (string) $ns->condition->attributes()->date.'<br/>'; } } else echo "Can't get Bristol Weather Yahoo RSS!"; BRISTOL / BORDEAUX example view commented code run code
example using php & simplexml() Webservicex REST service: (notoriously unreliable – yahoo weather might be better) http://www.webservicex.net/ http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=Bordeaux&CountryName=France http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=Bristol&CountryName=United Kingdom BRISTOL / BORDEAUX example
Webservicex REST service response (Bordeaux weather) : <?xml version="1.0" encoding="utf-8" ?> <string xmlns="http://www.webserviceX.NET"> <?xml version="1.0" encoding="utf-16"?> <CurrentWeather> <Location>Bordeaux / Merignac, France (LFBD) 44-50N 000-42W 61M</Location> <Time>Nov 26, 2010 - 04:00 AM EST / 2010.11.26 0900 UTC</Time> <Wind> from the SSW (210 degrees) at 2 MPH (2 KT):0</Wind> <Visibility> greater than 7 mile(s):0</Visibility> <Temperature> 35 F (2 C)</Temperature> <DewPoint> 35 F (2 C)</DewPoint> <RelativeHumidity> 100%</RelativeHumidity> <Pressure> 29.91 in. Hg (1013 hPa)</Pressure> <Status>Success</Status> </CurrentWeather></string> </CurrentWeather></string> BRISTOL / BORDEAUX example
Process webservicex REST service response (Bordeaux weather) : require_once('utility_lib.php'); $url = 'http://www.webservicex.net/globalweather.asmx/GetWeather?CityName=Bordeaux&CountryName=France'; $file = get_file($url); preg_match('/(<Current.*?<\/CurrentWeather>)/s', $file, $matches); $xml = simplexml_load_string(html_entity_decode($matches[0])); echo $xml->Location.'<br/>'; echo $xml->Time.'<br/>'; echo $xml->Wind.'<br/>'; echo $xml->Temperature.'<br/>'; BRISTOL / BORDEAUX example view commented code run code
Getting and processing news feeds : Sources: Bristol (source: BBC): http://newsrss.bbc.co.uk/rss/local/bristol/front_page/rss.xml note keywords Bordeaux (source: Yahoo News Service): http://news.search.yahoo.com/rss?ei=UTF-8&p=france+bordeaux+news&fr=news-us-ss PHP script to get Bordeaux news: $url = 'http://news.search.yahoo.com/rss?ei=UTF-8&p=france+bordeaux+news&fr=news-us-ss'; $rss = @simplexml_load_string(get_file($url), 'SimpleXMLElement', LIBXML_NOCDATA); if($rss) { foreach($rss->channel->item as $item) { echo '<a href=\''.$item->link.'\'>'.$item->title.'</a><br/>'; } } else echo "Can't get Bristol Weather Yahoo RSS!"; run code view commented code BRISTOL / BORDEAUX example
Google static maps: http://maps.google.com/maps/api/staticmap ?center=Bordeaux,France&zoom=15&size=800x480&sensor=false zoom size size centre of map flickr photos (from public area): http://www.flickr.com/services/feeds/photos_public.gne ?tags=bristol,cathedral,history&tagmode=all tags (comma delimited) include all tags
putting it all together: i) set up a configuration file holding paths, api-keys and other data view the code for dsa_config.php ii) build a utility file holding functions and other common code view the code for dsa_utility.php iii) build a php a script to bring it all together view the code for index.php Run the example application here: http://www.cems.uwe.ac.uk/~p-chatterjee/php/dsa/index.php
registering your group: • a group registration application will be made available Monday 23rd January on • you will need to register your group with this application • the application will assign your group an id • note that without registration and without a group id – your work cannot be marked!!