{"id":5134,"date":"2013-11-12T05:01:37","date_gmt":"2013-11-11T18:01:37","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5134"},"modified":"2015-05-15T10:15:49","modified_gmt":"2015-05-15T00:15:49","slug":"phpjavascripthtml-public-json-asx-international-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-public-json-asx-international-tutorial\/","title":{"rendered":"PHP\/Javascript\/HTML Public JSON ASX International Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/asx_international_look.php?default=\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Public JSON ASX International Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/asx_international_look.jpg\" title=\"PHP\/Javascript\/HTML Public JSON ASX International Tutorial\" \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Public JSON ASX International Tutorial<\/p><\/div>\n<p>Here is a tutorial that introduces you to the idea that you can use public data sources of JSON data, for instance, to construct informational web applications.   Today we look at ASX (Shares) informational on the Australian Stock Exchange, and internationalize the project somewhat by adding a Language dropdown for translations (via <a target=_blank title='Google Translate' href='http:\/\/translate.google.com'>Google Translate<\/a> &#8230; thanks) purposes.<\/p>\n<p>So this tutorial builds on the previous <a target=_blank title='PHP\/Javascript\/HTML Public JSON ASX Usage Tutorial' href='#pjhpjaut'>PHP\/Javascript\/HTML Public JSON ASX Usage Tutorial<\/a> presented below.<\/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>The public data for today&#8217;s <a target=_blank title='click picture' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/asx_international_look.php?default=\">tutorial<\/a> regarding ASX share data is derived from data from <a target=_blank title='Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds | GoMashUp.  The one stop shop for mashup.  JSON, XML, RSS feeds.' href='http:\/\/gomashup.com\/cms\/Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds'>Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds | GoMashUp.  The one stop shop for mashup.  JSON, XML, RSS feeds.<\/a> for which we give thanks.<\/p>\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>.   It will help show you, as with the case here in this tutorial, that the data emanating from the link you are given may not satisfy json_decode&#8217;s expected data format, especially that derived from the use of file_get_contents.   The line of code &#8230;<\/p>\n<blockquote><p> $json = substr(str_replace(&#8216;industry-group&#8217;,&#8217;industrygroup&#8217;, str_replace(&#8216;company-name&#8217;,&#8217;companyname&#8217;, str_replace(&#8216;]}&#8217;,&#8217;]&#8217;, str_replace(&#8216;{x[&#8216;,'[&#8216;, str_replace(&#8216;&#8221;result&#8221;:&#8217;,&#8221;, str_replace(&#8220;)&#8221;, &#8220;&#8221;, str_replace(&#8220;?(&#8220;,&#8221;&#8221;,$pageContent))))))),1);\n<\/p><\/blockquote>\n<p> &#8230; is a reflection of massaging the data you might have to make it suitable for json_decode usage.  So, in practical terms you should try bare bones file_get_contents and json_decode calls for the URL you were given, and think optimistically, but if you run into trouble &#8230;<\/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='asx_international_look.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/asx_international_look.php_GETME\">asx_international_look.php<\/a><\/p>\n<p>At most times when there is the combination of PHP and Javascript, it is the Javascript embellishments that make the application marketable and salesworthy, and so it is here, in this tutorial, with the ASX Search and Google Image Search (but not for non-English runs) windows created via:<\/p>\n<ul>\n<li><a target=_blank title='window.open' href='http:\/\/www.w3schools.com\/jsref\/met_win_open.asp'>window.open<\/a><\/li>\n<\/ul>\n<p>The use of window.open can sometimes be blocked by web browsers depending on their settings and you can read a bit more about such issues <a target=_blank title='pop-up windows' href='http:\/\/en.wikipedia.org\/wiki\/Pop-up_ad'>here<\/a>.<\/p>\n<p>The windows.open also causes issues from a website <i>encased<\/i> within a Google Translate window, and for this reason the Google Image Search functionality was counted out for non-English uses of this program.<\/p>\n<p>One last tool of interest is the PHP command <a target=_blank title='var_dump' href='http:\/\/php.net\/manual\/en\/function.var-dump.php'>var_dump<\/a> which can be useful to display for the variable on the left hand side of your json_decode statement, like <i>var_dump($json_output)<\/i> in the case of this tutorial.<\/p>\n<hr \/>\n<p id='pjhpjaut'>Previous <a target=_blank title='PHP\/Javascript\/HTML Public JSON ASX Usage Tutorial' href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=5084'>HP\/Javascript\/HTML Public JSON ASX Usage 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\/asx_look.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"PHP\/Javascript\/HTML Public JSON ASX Usage Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/PHP_JSON_ASX.jpg\" title=\"PHP\/Javascript\/HTML Public JSON ASX Usage Tutorial\" \/><\/a><p class=\"wp-caption-text\">PHP\/Javascript\/HTML Public JSON ASX Usage Tutorial<\/p><\/div>\n<p>Here is a tutorial that introduces you to the idea that you can use public data sources of JSON data, for instance, to construct informational web applications.   Today we look at ASX (Shares) informational on the Australian Stock Exchange.<\/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>The public data for today&#8217;s <a target=_blank title='click picture' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/asx_look.php\">tutorial<\/a> regarding ASX share data is derived from data from <a target=_blank title='Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds | GoMashUp.  The one stop shop for mashup.  JSON, XML, RSS feeds.' href='http:\/\/gomashup.com\/cms\/Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds'>Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds | GoMashUp.  The one stop shop for mashup.  JSON, XML, RSS feeds.<\/a> for which we give thanks.<\/p>\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>.   It will help show you, as with the case here in this tutorial, that the data emanating from the link you are given may not satisfy json_decode&#8217;s expected data format, especially that derived from the use of file_get_contents.   The line of code &#8230;<\/p>\n<blockquote><p> $json = substr(str_replace(&#8216;industry-group&#8217;,&#8217;industrygroup&#8217;, str_replace(&#8216;company-name&#8217;,&#8217;companyname&#8217;, str_replace(&#8216;]}&#8217;,&#8217;]&#8217;, str_replace(&#8216;{x[&#8216;,'[&#8216;, str_replace(&#8216;&#8221;result&#8221;:&#8217;,&#8221;, str_replace(&#8220;)&#8221;, &#8220;&#8221;, str_replace(&#8220;?(&#8220;,&#8221;&#8221;,$pageContent))))))),1);\n<\/p><\/blockquote>\n<p> &#8230; is a reflection of massaging the data you might have to make it suitable for json_decode usage.  So, in practical terms you should try bare bones file_get_contents and json_decode calls for the URL you were given, and think optimistically, but if you run into trouble &#8230;<\/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='asx_look.php' href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/JSON\/asx_look.php_GETME\">asx_look.php<\/a><\/p>\n<p>At most times when there is the combination of PHP and Javascript, it is the Javascript embellishments that make the application marketable and salesworthy, and so it is here, in this tutorial, with the ASX Search and Google Image Search windows created via:<\/p>\n<ul>\n<li><a target=_blank title='window.open' href='http:\/\/www.w3schools.com\/jsref\/met_win_open.asp'>window.open<\/a><\/li>\n<\/ul>\n<p>The use of window.open can sometimes be blocked by web browsers depending on their settings and you can read a bit more about such issues <a target=_blank title='pop-up windows' href='http:\/\/en.wikipedia.org\/wiki\/Pop-up_ad'>here<\/a>.<\/p>\n<p>One last tool of interest is the PHP command <a target=_blank title='var_dump' href='http:\/\/php.net\/manual\/en\/function.var-dump.php'>var_dump<\/a> which can be useful to display for the variable on the left hand side of your json_decode statement, like <i>var_dump($json_output)<\/i> in the case of this tutorial.<\/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='#d5084' onclick='var dv=document.getElementById(\"d5084\"); 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='d5084' 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='#d5134' onclick='var dv=document.getElementById(\"d5134\"); 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='d5134' 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 introduces you to the idea that you can use public data sources of JSON data, for instance, to construct informational web applications. Today we look at ASX (Shares) informational on the Australian Stock Exchange, and &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/phpjavascripthtml-public-json-asx-international-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":[8,12,37],"tags":[110,532,576,620,652,932,997,1136,1319],"class_list":["post-5134","post","type-post","status-publish","format-standard","hentry","category-data-integration","category-elearning","category-tutorials","tag-asx","tag-google-translate","tag-html","tag-internationalization","tag-javascript","tag-php","tag-programming","tag-shares","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/5134"}],"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=5134"}],"version-history":[{"count":1,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/5134\/revisions"}],"predecessor-version":[{"id":14834,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/5134\/revisions\/14834"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=5134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=5134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=5134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}