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 Google Translate … thanks) purposes.
So this tutorial builds on the previous PHP/Javascript/HTML Public JSON ASX Usage Tutorial presented below.
The two big PHP functions of use are:
The public data for today’s tutorial regarding ASX share data is derived from data from Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds | GoMashUp. The one stop shop for mashup. JSON, XML, RSS feeds. for which we give thanks.
Another tool you should have in your armoury for jobs like this is the online JSON validator here. 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’s expected data format, especially that derived from the use of file_get_contents. The line of code …
$json = substr(str_replace(‘industry-group’,’industrygroup’, str_replace(‘company-name’,’companyname’, str_replace(‘]}’,’]’, str_replace(‘{x[‘,'[‘, str_replace(‘”result”:’,”, str_replace(“)”, “”, str_replace(“?(“,””,$pageContent))))))),1);
… 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 …
- Type the URL you were given into a web browser address bar and have a look at it
- Type the URL you were given into http://jsonlint.com/ and have it validated
- Understand in your own mind what would be different about 1. to make it suitable
- Incorporate findings of 3. into massaging of data between file_get_contents and json_decode
Here is a link to some downloadable PHP programming source code which you may want to rename to asx_international_look.php
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:
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 here.
The windows.open also causes issues from a website encased within a Google Translate window, and for this reason the Google Image Search functionality was counted out for non-English uses of this program.
One last tool of interest is the PHP command var_dump which can be useful to display for the variable on the left hand side of your json_decode statement, like var_dump($json_output) in the case of this tutorial.
Previous HP/Javascript/HTML Public JSON ASX Usage Tutorial is shown below.
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.
The two big PHP functions of use are:
The public data for today’s tutorial regarding ASX share data is derived from data from Australian%20Securities%20Exchange%20ASX%20Code%20JSON%20Data%20Feeds | GoMashUp. The one stop shop for mashup. JSON, XML, RSS feeds. for which we give thanks.
Another tool you should have in your armoury for jobs like this is the online JSON validator here. 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’s expected data format, especially that derived from the use of file_get_contents. The line of code …
$json = substr(str_replace(‘industry-group’,’industrygroup’, str_replace(‘company-name’,’companyname’, str_replace(‘]}’,’]’, str_replace(‘{x[‘,'[‘, str_replace(‘”result”:’,”, str_replace(“)”, “”, str_replace(“?(“,””,$pageContent))))))),1);
… 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 …
- Type the URL you were given into a web browser address bar and have a look at it
- Type the URL you were given into http://jsonlint.com/ and have it validated
- Understand in your own mind what would be different about 1. to make it suitable
- Incorporate findings of 3. into massaging of data between file_get_contents and json_decode
Here is a link to some downloadable PHP programming source code which you may want to rename to asx_look.php
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:
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 here.
One last tool of interest is the PHP command var_dump which can be useful to display for the variable on the left hand side of your json_decode statement, like var_dump($json_output) in the case of this tutorial.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.