{"id":16353,"date":"2015-08-03T05:01:11","date_gmt":"2015-08-02T19:01:11","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=16353"},"modified":"2015-08-02T21:04:14","modified_gmt":"2015-08-02T11:04:14","slug":"yahoo-yql-web-service-json-data-uri-pdf-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-web-service-json-data-uri-pdf-tutorial\/","title":{"rendered":"Yahoo YQL Web Service JSON data.uri PDF Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/data_uri_yql.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Yahoo YQL Web Service JSON data.uri PDF Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/yql_data_uri.gif\" title=\"Yahoo YQL Web Service JSON data.uri PDF Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Yahoo YQL Web Service JSON data.uri PDF Tutorial<\/p><\/div>\n<p>Today, we follow up on yesterday&#8217;s <a target=_blank title='' href='#yywsjdt'>Yahoo YQL Web Service JSON data.uri Tutorial<\/a> as shown below, by adding a display in PDF of the image data, as an extra piece of functionality.<\/p>\n<p>We use the incredibly useful PHP <a target=_blank title='PHP ImageMagick class' href='http:\/\/php.net\/manual\/en\/book.imagick.php'>ImageMagick<\/a> class functionality to do the conversion to PDF from the image formats, and only perform the conversion if the data uri is possible to use via the use of the Yahoo YQL Web Service data.uri methods.<\/p>\n<p>As this involves storing files on a server, so there is the necessity of using a server-side language like PHP.  We restrict PDF display to image files on the http:\/\/www.rjmprogramming.com.au domain, as these are files I&#8217;m happy for you to try, so, if you have trouble finding these, you can examine http:\/\/www.rjmprogramming.com.au domain webpages and use &#8230;<\/p>\n<ul>\n<li>View-&gt;Page Source web browser options &#8230; or a &#8230;<\/li>\n<li>Web Inspector (like Firefox&#8217;s Firebug) &#8230; or &#8230;<\/li>\n<li>Right Click an image and get <i>image information<\/i><\/li>\n<\/ul>\n<p> &#8230; but, as for yesterday, bear in mind that there is a 25600 byte limit to the Yahoo YQL data.uri Web Service conversions.<\/p>\n<p>It is not only this type of conversion that the PHP <a target=_blank title='PHP ImageMagick class' href='http:\/\/php.net\/manual\/en\/class.imagick.php'>ImageMagick<\/a> class functionality can help with, and we strongly encourage you to examine it more as a wonderful tool for graphics and media work.  We installed it onto our local MAMP server via the <a target=_blank title='MacPorts' href='https:\/\/www.macports.org\/'>MacPorts<\/a> command (in the Mac application Terminal) &#8230;<\/p>\n<p><code><br \/>\nsudo port install ImageMagick<br \/>\n<\/code><\/p>\n<p> &#8230; as you can see over to the top right of <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/yql_data_uri.gif\" title='Click picture'>today&#8217;s tutorial picture<\/a>.<\/p>\n<p>We&#8217;ll leave you today with our PHP code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/data_uri_yql.php-GETME\" title='data_uri_yql.php'>data_uri_yql.php<\/a> which changed from yesterday&#8217;s code <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/data_uri_yql.php-GETME\" title='data_uri_yql.php'>in this way<\/a>.<\/p>\n<hr>\n<p id='yywsjdt'>Previous relevant <a target=_blank title='' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-web-service-json-data-uri-tutorial\/'>Yahoo YQL Web Service JSON data.uri 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\/YQL\/DataUri\/data_uri_yql.php\"><img decoding=\"async\" style=\"float:left; border: 15px solid pink;\" alt=\"Yahoo YQL Web Service JSON data.uri Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/yql_data_uri.jpg\" title=\"Yahoo YQL Web Service JSON data.uri Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Yahoo YQL Web Service JSON data.uri Tutorial<\/p><\/div>\n<p>Here is a tutorial that might be re-introducing you to the Yahoo Web Services called YQL, building on previous ones here at this <a href='http:\/\/www.rjmprogramming.com.au\/wordpress\/?tag=YQL' title='Yahoo YQL tutorials here'>blog<\/a>.   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 data.uri web service database with Yahoo YQL website &#8230; thanks.<\/p>\n<p>We&#8217;ve talked in passing about the data.uri concept before.  In the case of an HTML <a target=_blank title='HTML img tag information from w3schools' href='http:\/\/www.w3schools.com\/tags\/tag_img.asp'><i>img<\/i><\/a> tag&#8217;s definition you can specify the src= value in three different ways &#8230;<\/p>\n<ol>\n<li>as an address via an http: or https: protocol URL such as http:\/\/www.rjmprogramming.com.au\/MyBusinessUnidad\/Welcome_files\/logo.jpg (our default)<\/li>\n<li>as an address via a local file: protocol URL such as file:\/\/\/Library\/pgAgent\/Desktop\/dynamic_javascript.jpg accessing a local image on the local computer being used (like you can make happen when you access your web browser&#8217;s File-&gt;Open File&#8230; functionality)<\/li>\n<li>as a <a target=_blank title='Data uri information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Data_URI_scheme'>data uri<\/a> value which is a way to fully define the image data there and then, using <a target=_blank title='base64 information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Base64'>base64<\/a> data<\/li>\n<\/ol>\n<p>What this data.uri Yahoo Yql web service is providing, is a way to create a data uri from an http: or https: URL definition of a media file (image in our thinking above) &#8230; but, please note there is a 25600 byte limit to the size of the media file.<\/p>\n<p>In our application today we show you an HTML <i>img<\/i> tag of the data on the parent page (the Firefox browser Firebug add on is showing you the resultant data uri) with a Javascript code scenario &#8230;<\/p>\n<p><code><br \/>\nvar thedatauri = 'data:image\/jpeg;charset=UTF-8;base64,&lt;!-- base64 data --&gt;';<br \/>\nvar wo=window.open('', 'imagename.jpg', 'top=400,left=400,width=200,height=200,resizable=yes');<br \/>\nwo.document.write('&lt;img src=\"' + thedatauri + '\" \/&gt;');<br \/>\n<\/code><\/p>\n<p> &#8230; arranged by today&#8217;s PHP code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/data_uri_yql.php_GETME\" title='data_uri_yql.php'>data_uri_yql.php<\/a> or try a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/YQL\/DataUri\/data_uri_yql.php\" title='Click picture'>live run<\/a>.  In that way the HTML <i>img<\/i> data of the resultant popup window has no reference to any particular address on the web and would be useful for document fidelity purposes perhaps, as we&#8217;ve discussed previously on the blog <a target=_blank title='Document fidelity blog postings here' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/document-fidelity'>here<\/a>, because there is no trail back regarding its metadata.<\/p>\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\/#h=select+*+from+data.uri+where+url%3D%22http%3A%2F%2Fwww.rjmprogramming.com.au%2FMyBusinessUnidad%2FWelcome_files%2Flogo.jpg%22' title='YQL data.uri help'>YQL data.uri 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>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d16324' onclick='var dv=document.getElementById(\"d16324\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=yahoo-yql\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d16324' 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='#d16353' onclick='var dv=document.getElementById(\"d16353\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/?tag=json\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d16353' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Today, we follow up on yesterday&#8217;s Yahoo YQL Web Service JSON data.uri Tutorial as shown below, by adding a display in PDF of the image data, as an extra piece of functionality. We use the incredibly useful PHP ImageMagick class &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/yahoo-yql-web-service-json-data-uri-pdf-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,37],"tags":[1653,1654,297,350,438,439,1658,664,735,744,913,932,997,1252,1319,1487,1491,1494],"class_list":["post-16353","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","tag-base64","tag-data-uri","tag-data-url","tag-document-fidelity","tag-firebug","tag-firefox","tag-imagemagick","tag-json","tag-macports","tag-mamp","tag-pdf","tag-php","tag-programming","tag-terminal","tag-tutorial","tag-yahoo","tag-yahoo-yql","tag-yql"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16353"}],"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=16353"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16353\/revisions"}],"predecessor-version":[{"id":16364,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/16353\/revisions\/16364"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=16353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=16353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=16353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}