{"id":10613,"date":"2014-11-16T05:06:19","date_gmt":"2014-11-15T18:06:19","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10613"},"modified":"2014-11-16T05:06:19","modified_gmt":"2014-11-15T18:06:19","slug":"yahoo-yql-web-service-json-winter-olympics-game-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-web-service-json-winter-olympics-game-tutorial\/","title":{"rendered":"Yahoo YQL Web Service Winter Olympics Game Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/winter_olympics.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Yahoo YQL Web Service Winter Olympics Game Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/winter_olympics.png\" title=\"Yahoo YQL Web Service Winter Olympics Game Tutorial\" id='ghtre' onmouseover=' this.src=this.src.replace(\".jpg\",\".PNG\").replace(\".png\",\".jpg\").replace(\".PNG\",\".png\");  ' \/><\/a><p class=\"wp-caption-text\">Yahoo YQL Web Service Winter Olympics Game Tutorial<\/p><\/div>\n<p>Here is a tutorial that reminds you again about the Yahoo Web Services called YQL, building on previous YQL <a href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=YQL' title='Yahoo YQL tutorials here'>tutorials<\/a> on this blog, building on yesterday&#8217;s <a target=_blank href='#yywsjfnt' title='Yahoo YQL Web Service JSON First Name Tutorial'>Yahoo YQL Web Service JSON First Name Tutorial<\/a> as shown below.   The name is the way it is because it simplified the API aspects of its functionality for the developer to concentrate on SQL, and I&#8217;m really supportive of this concept.  You don&#8217;t have to output in JSON, as other data forms like XML are acceptable.  Let&#8217;s see what Wikipedia says about YQL below. <\/p>\n<blockquote>\n<p>Yahoo! Query Language (YQL) is an SQL-like query language created by Yahoo! as part of their Developer Network. YQL is designed to retrieve and manipulate data from APIs through a single Web interface, thus allowing mashups that enable developers to create their own applications.[1]<\/p>\n<p>Initially launched in October 2008 with access to Yahoo APIs,[2] February 2009 saw the addition of open data tables from third parties such as Google Reader, the Guardian, and The New York Times.[3] Some of these APIs still require an API key to access them. On April 29th of 2009, Yahoo introduced the capability to execute the tables of data built through YQL using JavaScript run on the company&#8217;s servers for free.[3]<\/p>\n<\/blockquote>\n<p>So this tutorial uses a YQL web service into the data emanating from its links to a Winter Olympics database of the http:\/\/isithackday.com website (where they have a useful CSV file called medals.csv) &#8230; thanks.  You fill in a Medal Presentation (secret) number of interest to get presented with 5\/8 of the information required to score a point &#8230; your job, should you decide to take it on, <a target=_blank title='Mission What?' href='http:\/\/www.youtube.com\/watch?v=ZGInRtQo4S4'><i>Jim<\/i><\/a>, is to pick those other 3\/8 of the information.<\/p>\n<p>The two big PHP functions of use for this are (normally):<\/p>\n<ul>\n<li><a target=_blank title='file_get_contents' href='http:\/\/us1.php.net\/file_get_contents'>file_get_contents<\/a><\/li>\n<li><a target=_blank title='json_decode' href='http:\/\/php.net\/manual\/en\/function.json-decode.php'>json_decode<\/a> &#8230; but today we prefer to read the medals.csv file as mentioned above to derive information required to run the game &#8230; it&#8217;s the same information as you&#8217;d need to walk the game actually &#8230; this approach to the Winter Olympics game came about as a result of perusing the arrangements for <a target=_blank href='https:\/\/developer.yahoo.com\/yql\/console\/?q=select%20*%20from%20flickr.photos.interestingness%2820%29&#038;env=store:\/\/datatables.org\/alltableswithkeys#h=select+*+from+wintermedals+where+country%3D%22GBR%22+and+type%3D%22Gold%22%3B' title='YQL wintermedals help'>wintermedals<\/a> and saw that this was a good pared down arrangement &#8230; data can be handled in a large variety of ways<\/li>\n<\/ul>\n<p>Good links for information regarding this tutorial (thanks) are:<\/p>\n<ul>\n<li><a target=_blank href='http:\/\/developer.yahoo.com\/yql\/guide\/two-minute-tutorial.html' title='YQL Two Minute Tutorial'>YQL Two Minute Tutorial<\/a> from Yahoo<\/li>\n<li><a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/Yahoo!_Query_Language' title='Yahoo! Query Language'>Yahoo! Query Language<\/a> from Wikipedia, as per quote above<\/li>\n<li><a target=_blank href='http:\/\/developer.yahoo.com\/yql\/' title='YQL Home Page'>YQL Home Page<\/a> from Yahoo<\/li>\n<li><a target=_blank href='https:\/\/developer.yahoo.com\/yql\/console\/?q=select%20*%20from%20flickr.photos.interestingness%2820%29&#038;env=store:\/\/datatables.org\/alltableswithkeys#h=select+*+from+wintermedals+where+country%3D%22GBR%22+and+type%3D%22Gold%22%3B' title='YQL wintermedals help'>YQL wintermedals help<\/a> from Yahoo<\/li>\n<li><a target=_blank title='YQL JSON Parsing Help' href='http:\/\/developer.yahoo.com\/forum\/YQL\/yql-query-intermittently-returns-no-results\/1374521623593-fa4a3519-10ae-4a17-8fd4-6de45a159d6f'>YQL JSON Parsing Help<\/a> from YQL forum<\/li>\n<\/ul>\n<p>There are three live run ideas &#8230;<\/p>\n<ul>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/winter_olympics.php\" title=\"Winter Olympics Game Live Run\">Winter Olympics Game Live Run<\/a> &#8230; where you pick a Medals Presentation (secret) number &#8230; though Firebug afficianados may laugh heartily here<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/winter_olympics.php?pickone=\" title=\"Winter Olympics Game Random Live Run\">Winter Olympics Game Random Live Run<\/a> &#8230; where you have a random Medals Presentation (secret) number picked for you<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/winter_olympics.php?pickone=2313\" title=\"Winter Olympics Game Random Live Run\">Winter Olympics Game Particular Live Run<\/a> &#8230; where you have a Medals Presentation (secret) number specified by you (eg. 2313)<\/li>\n<\/ul>\n<p>Another tool you should have in your armoury for jobs like this is the online JSON validator <a target=_blank title='JSON validator online' href='http:\/\/jsonlint.com\/'>here<\/a>.  A generic JSON approach to issues could be:<\/p>\n<ol>\n<li>Type the URL you were given into a web browser address bar and have a look at it<\/li>\n<li>Type the URL you were given into http:\/\/jsonlint.com\/ and have it validated<\/li>\n<li>Understand in your own mind what would be different about 1. to make it suitable<\/li>\n<li>Incorporate findings of 3. into massaging of data between file_get_contents and json_decode<\/li>\n<\/ol>\n<p>Here is a link to some downloadable PHP programming source code which you may want to rename to <a target=_blank title='winter_olympics.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/winter_olympics.php_GETME\">winter_olympics.php<\/a><\/p>\n<p>Thanks to Google for the research link access to search engine queries accessed via <a target=_blank title='window.open information from w3schools ... thanks' href='http:\/\/www.w3schools.com\/jsref\/met_win_open.asp'>window.open<\/a> Javascript calls.<\/p>\n<hr \/>\n<p id='yywsjfnt'>Previous relevant <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=10607' title='Yahoo YQL Web Service JSON First Name Tutorial'>Yahoo YQL Web Service JSON First Name Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/first_name.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Yahoo YQL Web Service JSON First Name Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/first_name.jpg\" title=\"Yahoo YQL Web Service JSON Frst Name Tutorial\" \/><\/a><p class=\"wp-caption-text\">Yahoo YQL Web Service JSON First Name Tutorial<\/p><\/div>\n<p>Here is a tutorial that re-introduces you to the Yahoo Web Services called YQL, building on previous YQL <a href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=YQL' title='Yahoo YQL tutorials here'>tutorials<\/a> on this blog.   The name is the way it is because it simplified the API aspects of its functionality for the developer to concentrate on SQL, and I&#8217;m really supportive of this concept.  You don&#8217;t have to output in JSON, as other data forms like XML are acceptable.  Let&#8217;s see what Wikipedia says about YQL below. <\/p>\n<blockquote>\n<p>Yahoo! Query Language (YQL) is an SQL-like query language created by Yahoo! as part of their Developer Network. YQL is designed to retrieve and manipulate data from APIs through a single Web interface, thus allowing mashups that enable developers to create their own applications.[1]<\/p>\n<p>Initially launched in October 2008 with access to Yahoo APIs,[2] February 2009 saw the addition of open data tables from third parties such as Google Reader, the Guardian, and The New York Times.[3] Some of these APIs still require an API key to access them. On April 29th of 2009, Yahoo introduced the capability to execute the tables of data built through YQL using JavaScript run on the company&#8217;s servers for free.[3]<\/p>\n<\/blockquote>\n<p>So this tutorial uses a YQL web service into the data emanating from its links to the First Names (firstnames) database of the www.thomas-bayer.com website &#8230; thanks.  You fill in a First Name of interest to search for contributary country data regarding that name&#8217;s usage at the Yahoo YQL firstname www.thomas-bayer.com database tables.<\/p>\n<p>The two big PHP functions of use for this are (normally):<\/p>\n<ul>\n<li><a target=_blank title='file_get_contents' href='http:\/\/us1.php.net\/file_get_contents'>file_get_contents<\/a><\/li>\n<li><a target=_blank title='json_decode' href='http:\/\/php.net\/manual\/en\/function.json-decode.php'>json_decode<\/a> &#8230; but today we prefer to get the raw data and use PHP <a target=_blank title='PHP explode function' href='http:\/\/php.net\/manual\/en\/function.explode.php'>explode<\/a> function to extract arrays we can use as a means to present the data<\/li>\n<\/ul>\n<p>Good links for information regarding this tutorial (thanks) are:<\/p>\n<ul>\n<li><a target=_blank href='http:\/\/developer.yahoo.com\/yql\/guide\/two-minute-tutorial.html' title='YQL Two Minute Tutorial'>YQL Two Minute Tutorial<\/a> from Yahoo<\/li>\n<li><a target=_blank href='http:\/\/en.wikipedia.org\/wiki\/Yahoo!_Query_Language' title='Yahoo! Query Language'>Yahoo! Query Language<\/a> from Wikipedia, as per quote above<\/li>\n<li><a target=_blank href='http:\/\/developer.yahoo.com\/yql\/' title='YQL Home Page'>YQL Home Page<\/a> from Yahoo<\/li>\n<li><a target=_blank href='https:\/\/developer.yahoo.com\/yql\/console\/?q=select%20*%20from%20flickr.photos.interestingness%2820%29&#038;env=store:\/\/datatables.org\/alltableswithkeys#h=SELECT+*+FROM+firstnames.lookup+WHERE+name%3D%22Sebastian%22' title='YQL firstnames help'>YQL firstnames help<\/a> from Yahoo<\/li>\n<li><a target=_blank title='YQL JSON Parsing Help' href='http:\/\/developer.yahoo.com\/forum\/YQL\/yql-query-intermittently-returns-no-results\/1374521623593-fa4a3519-10ae-4a17-8fd4-6de45a159d6f'>YQL JSON Parsing Help<\/a> from YQL forum<\/li>\n<\/ul>\n<p>Another tool you should have in your armoury for jobs like this is the online JSON validator <a target=_blank title='JSON validator online' href='http:\/\/jsonlint.com\/'>here<\/a>.  A generic JSON approach to issues could be:<\/p>\n<ol>\n<li>Type the URL you were given into a web browser address bar and have a look at it<\/li>\n<li>Type the URL you were given into http:\/\/jsonlint.com\/ and have it validated<\/li>\n<li>Understand in your own mind what would be different about 1. to make it suitable<\/li>\n<li>Incorporate findings of 3. into massaging of data between file_get_contents and json_decode<\/li>\n<\/ol>\n<p>Here is a link to some downloadable HTML programming source code which you may want to rename to <a target=_blank title='first_name.html' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/first_name.html_GETME\">first_name.html<\/a> which calls some downloadable PHP programming source code which you may want to rename to <a target=_blank title='first_name.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/first_name.php_GETME\">first_name.php<\/a><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d7529' onclick='var dv=document.getElementById(\"d7529\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=JSON\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d7529' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d10607' onclick='var dv=document.getElementById(\"d10607\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=YQL\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10607' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr \/>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d10613' onclick='var dv=document.getElementById(\"d10613\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=CSV\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d10613' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is a tutorial that reminds you again about the Yahoo Web Services called YQL, building on previous YQL tutorials on this blog, building on yesterday&#8217;s Yahoo YQL Web Service JSON First Name Tutorial as shown below. The name is &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-web-service-json-winter-olympics-game-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,15,37],"tags":[290,429,476,513,652,932,997,1319,1412,1433,1491,1494],"class_list":["post-10613","post","type-post","status-publish","format-standard","hentry","category-elearning","category-games","category-tutorials","tag-data","tag-file_get_contents","tag-game","tag-google","tag-javascript","tag-php","tag-programming","tag-tutorial","tag-web-service","tag-window-open","tag-yahoo-yql","tag-yql"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10613"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=10613"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/10613\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=10613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=10613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=10613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}