{"id":13656,"date":"2015-03-24T05:01:42","date_gmt":"2015-03-23T18:01:42","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=13656"},"modified":"2015-03-24T05:01:42","modified_gmt":"2015-03-23T18:01:42","slug":"yahoo-yql-nextbus-json-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-nextbus-json-primer-tutorial\/","title":{"rendered":"Yahoo YQL Nextbus JSON Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/yqlnextbus.html\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Yahoo YQL Nextbus JSON Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/yqlnextbus.jpg\" title=\"Yahoo YQL Nextbus JSON Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Yahoo YQL Nextbus JSON Primer Tutorial<\/p><\/div>\n<p>If we add some of the ideas of <a target=_blank title='HTML\/Javascript Geolocation Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=8595'>HTML\/Javascript Geolocation Primer Tutorial<\/a> to yesterday&#8217;s <a target=_blank title='Yahoo YQL Geodata JSON Primer Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=13627'>Yahoo YQL Geodata JSON Primer Tutorial<\/a> we may well arrive at the logic and a large part of the content ideas for today&#8217;s tutorial, where we track buses on maps with realtime snapshots, that may be introducing (or reintroducing) you to the Yahoo Web Services called YQL.   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 the Nextbus realtime bus locator database.  You select a bus route of interest, and optionally select a distance range of relevance, and the web application goes away to derive geographical latitude and longitude and bus location details from the Yahoo Yql Nextbus database.<\/p>\n<p>The two big PHP functions of use are:<\/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><\/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+nextbus.vehicles+where+route%3D%27N%27' title='YQL Yahoo Geodata help'>YQL Yahoo Nextbus<\/font> 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>The brilliance of Yahoo YQL and its <a target=_blank href='http:\/\/webservices.nextbus.com' title='Nextbus web service'>Nextbus<\/a> database meets the brilliance of Google Charts (and I daresay Google Maps) today as the web application uses a <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=4832' title='PHP\/Javascript\/HTML Google Chart Map Tutorial'>Google Chart Map Chart<\/a> to display where the Nextbus buses are, in (snapshot) realtime, as well as your position, if relevant (by comparing bus positions versus your position within your designated range), via the geolocation Javascript functionality inbuilt into the web application &#8230; thanks everybody.   Also relevant was this previous <a target=_blank href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5339' title='PHP\/Javascript\/HTML Great Circle Distance Tutorial'>PHP\/Javascript\/HTML Great Circle Distance Tutorial<\/a> where its Javascript logic for calculating Great Circle Distances on Earth was the inspiration for a PHP function to do the same functionality.<\/p>\n<p>Here is a link to some downloadable HTML programming source code which you may want to rename to <a target=_blank title='yqlnextbus.html' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/yqlnextbus.html_GETME\">yqlnextbus.html<\/a> which calls some downloadable PHP programming source code which you may want to rename to <a target=_blank title='yqlnextbus.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/yqlnextbus.php_GETME\">yqlnextbus.php<\/a> and a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/YQL\/yqlnextbus.html\" title='Click picture'>live run<\/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='#d13656' onclick='var dv=document.getElementById(\"d13656\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=geographicals\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d13656' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If we add some of the ideas of HTML\/Javascript Geolocation Primer Tutorial to yesterday&#8217;s Yahoo YQL Geodata JSON Primer Tutorial we may well arrive at the logic and a large part of the content ideas for today&#8217;s tutorial, where we &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-nextbus-json-primer-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,21,37],"tags":[480,481,483,513,519,527,576,932,997,1029,1161,1186,1319,1412,1487,1488,1494],"class_list":["post-13656","post","type-post","status-publish","format-standard","hentry","category-elearning","category-land-surveying","category-tutorials","tag-geodata","tag-geographicals","tag-geolocation","tag-google","tag-google-charts","tag-google-maps","tag-html","tag-php","tag-programming","tag-realtime","tag-snapshot","tag-sql","tag-tutorial","tag-web-service","tag-yahoo","tag-yahoo-answers","tag-yql"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/13656"}],"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=13656"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/13656\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=13656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=13656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=13656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}