1 / 13

(Another) Assignment Q&A

(Another) Assignment Q&A. Appreciating the context … or What are we trying to do? … building an application using external services … or a “service oriented” application. Source : Zdnet. Minimum Requirements / Deliverables (relaxed version). 3 / 4 components depending on group size

oriel
Download Presentation

(Another) Assignment Q&A

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. (Another) Assignment Q&A

  2. Appreciating the context … or What are we trying to do? … building an application using external services … or a “service oriented” application

  3. Source : Zdnet

  4. 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

  5. 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

  6. 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.'&deg;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

  7. 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

  8. 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

  9. 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('/(&lt;Current.*?&lt;\/CurrentWeather&gt;)/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

  10. 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

  11. 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

  12. 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

  13. 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!!

More Related