{"id":70099,"date":"2021-08-25T04:10:07","date_gmt":"2021-08-25T08:10:07","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/code-example-utilizing-web-services-in-php-16\/"},"modified":"2021-08-25T04:10:07","modified_gmt":"2021-08-25T08:10:07","slug":"code-example-utilizing-web-services-in-php-16","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=70099","title":{"rendered":"Code Example: Utilizing Web Services in PHP #16"},"content":{"rendered":"<pre style=\"padding:15px\">PHP code to grab the best provincial mortgage rate:function find_mortgaze_rate($url){ \/\/ create a new cURL resource   $ch = curl_init();  \/\/ set URL and other appropriate options    curl_setopt($ch, CURLOPT_URL, $url);    curl_setopt($ch, CURLOPT_USERPWD, \"username:password\"); curl_setopt($ch, CURLOPT_HEADER, 0);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);        \/\/ grab URL and pass it to the browser  $result = curl_exec($ch);   $bestRates = json_decode($result, true);    return $bestRates[1][5][0]['rate']; \/\/ close cURL resource, and free up system resources    curl_close($ch);    return $bestMortgaze;    }\/\/supply URL to ProvidingMortgazeRatesForEachProvinceForDifferentYearsAndType$bestMortgaze = find_mortgaze_rate($urlToTheWebService);<\/pre>\n<pre style=\"padding:10px\">Sample JavaScript Function to calculate the monthly mortgaze paymentfunction calculate(){    var rate = document.getElementById('txtRate').value;    var homePrice = document.getElementById('txtHomePrice').value;  var percentDown = document.getElementById('txtDownpaymentPercent').value;   var amortization = document.getElementById('amortization').value;   var monthlyPayment = can_mortgage_payment_purchase(homePrice, percentDown\/100,  rate\/100, amortization, 12, 1); document.getElementById('monthlyPayment').value = '$'+monthlyPayment.toFixed(2);}<\/pre>\n<pre style='padding:15px'>Calculator Form Code       <table>     <tr>            <td>                Best 5 Year Fixed Rate:         <\/td>           <td>                            <\/td>       <\/tr>       <tr>            <td>                Home Price:         <\/td>           <td>                            <\/td>       <\/tr>       <tr>            <td>                Downpayment Percentage:         <\/td>           <td>                            <\/td>       <\/tr>       <tr>            <td>                Amortization:           <\/td>           <td>                                    25 Years                    30 Years                            <\/td>       <\/tr>       <tr>            <td colspan=\"2\">                            <\/td>       <\/tr>       <tr>            <td>                Mortgage Payment:           <\/td>           <td colspan=\"2\">                            <\/td>       <\/tr>   <\/table><\/pre>\n<p>From: http:\/\/sitestree.com\/?p=5302<br \/> Categories:16<br \/>Tags:<br \/> Post Data:2009-11-03 18:40:09<\/p>\n<pre><code>    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\"&gt;https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    (Big Data, Cloud, Security, Machine Learning): Courses: &lt;a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"&gt; http:\/\/Training.SitesTree.com&lt;\/a&gt; \n    In Bengali: &lt;a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\"&gt;http:\/\/Bangla.SaLearningSchool.com&lt;\/a&gt;\n    &lt;a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\"&gt;http:\/\/SitesTree.com&lt;\/a&gt;\n    8112223 Canada Inc.\/JustEtc: &lt;a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\"&gt;http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) &lt;\/a&gt;\n    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com'&gt; https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    Medium: &lt;a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"&gt; https:\/\/medium.com\/@SayedAhmedCanada &lt;\/a&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PHP code to grab the best provincial mortgage rate:function find_mortgaze_rate($url){ \/\/ create a new cURL resource $ch = curl_init(); \/\/ set URL and other appropriate options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, &#8220;username:password&#8221;); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); \/\/ grab URL and pass it to the browser $result = curl_exec($ch); $bestRates = json_decode($result, true); return &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=70099\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-70099","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":20795,"url":"http:\/\/bangla.sitestree.com\/?p=20795","url_meta":{"origin":70099,"position":0},"title":"Scraping HTML Content","author":"Author-Check- Article-or-Video","date":"February 27, 2021","format":false,"excerpt":"HTML DOM Parser Works well: http:\/\/net.tutsplus.com\/tutorials\/php\/html-parsing-and-screen-scraping-with-the-simple-html-dom-library\/ http:\/\/sourceforge.net\/projects\/simplehtmldom\/ PHP XML parsers will work though the HTML needs to be perfect (XHTML) : http:\/\/www.php.net\/manual\/en\/refs.xml.php Example: http:\/\/www.php.net\/manual\/en\/simplexml.examples.php \u00a0 To grab HTML from a URL, you can use CURL \/\/ create a new cURL resource $ch = curl_init(); \/\/ set URL and other appropriate\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7506,"url":"http:\/\/bangla.sitestree.com\/?p=7506","url_meta":{"origin":70099,"position":1},"title":"C &#8211; Strings . \u09b8\u09bf \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09bf\u0982 \u098f \u09b8\u09cd\u099f\u09cd\u09b0\u09bf\u0982","author":"Author-Check- Article-or-Video","date":"March 25, 2015","format":false,"excerpt":"C - Strings \u09ae\u09cb\u0983 \u0986\u09ac\u09cd\u09a6\u09c1\u09b2\u09cd\u09b2\u09be\u09b9 \u09b8\u09bf \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09bf\u0982 \u098f \u09b8\u09cd\u099f\u09cd\u09b0\u09bf\u0982 \u09b9\u09b2 \u09ae\u09c1\u09b2\u09a4 \u098f\u0995 \u09a1\u09be\u0987\u09ae\u09c7\u09a8\u09b6\u09a8\u09c7\u09b0 array \u09af\u09be \u0995\u09bf\u09a8\u09be \u09b6\u09c7\u09b7 \u09b9\u09df '\\0' \u09ac\u09be null character \u09a6\u09bf\u09df\u09c7 \u0964 \u09a8\u09bf\u09ae\u09cd\u09a8\u09c7\u09b0 \u09ac\u09bf\u09ac\u09c3\u09a4\u09bf \u098f\u09ac\u0982 \u0989\u09a6\u09cd\u09a7\u09c3\u09a4\u09bf\u099f\u09bf \u098f\u09ae\u09a8 \u098f\u0995\u099f\u09bf \u09b8\u09cd\u099f\u09cd\u09b0\u09bf\u0982 \u09a4\u09c8\u09b0\u09c0 \u0995\u09b0\u09c7 \u09af\u09be \"Hello\" \u09b8\u09cd\u099f\u09cd\u09b0\u09bf\u0982\u099f\u09bf \u09a7\u09be\u09b0\u09a3 \u0995\u09b0\u09c7\u0964 array \u09b0 \u09b6\u09c7\u09b7\u09c7 null character \u0995\u09c7 \u09a7\u09be\u09b0\u09a3 \u0995\u09b0\u09be\u09b0 \u099c\u09a8\u09cd\u09af array \u09b0 \u09a7\u09be\u09b0\u09a3\u0995\u09cd\u09b0\u09bf\u09a4\u2026","rel":"","context":"In &quot;\u09aa\u09cd\u09b0\u09be\u09a5\u09ae\u09bf\u0995 \u09b8\u09bf \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09bf\u0982 \u0964 C Programming Basics&quot;","block_context":{"text":"\u09aa\u09cd\u09b0\u09be\u09a5\u09ae\u09bf\u0995 \u09b8\u09bf \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09bf\u0982 \u0964 C Programming Basics","link":"http:\/\/bangla.sitestree.com\/?cat=239"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9598,"url":"http:\/\/bangla.sitestree.com\/?p=9598","url_meta":{"origin":70099,"position":2},"title":"\u0987\u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u09aa\u09cd\u09b0\u09b8\u09c7\u09b8 \u09ae\u09cd\u09af\u09be\u09a8\u09c7\u099c\u09ae\u09c7\u09a8\u09cd\u099f (Unix &#8211; Processes Management)","author":"Author-Check- Article-or-Video","date":"July 1, 2015","format":false,"excerpt":"\u09b0\u09bf\u09a6\u0993\u09df\u09be\u09a8 \u09ac\u09bf\u09a8 \u09b6\u09be\u09ae\u09c0\u09ae \u00a0 \u0987\u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u09b8\u09bf\u09b8\u09cd\u099f\u09c7\u09ae\u09c7 \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u09b0\u09be\u09a8 \u0995\u09b0\u09be\u09a8\u09cb\u09b0 \u09b8\u09ae\u09df \u09b8\u09bf\u09b8\u09cd\u099f\u09c7\u09ae \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae\u09c7\u09b0 \u0989\u09aa\u09af\u09c1\u0995\u09cd\u09a4 \u09aa\u09b0\u09bf\u09ac\u09c7\u09b6 \u09a4\u09c8\u09b0\u09bf \u0995\u09b0\u09c7 \u09a8\u09c7\u09df\u0964 \u0985\u09aa\u09be\u09b0\u09c7\u099f\u09bf\u0982 \u09b8\u09bf\u09b8\u09cd\u099f\u09c7\u09ae pid \u09ac\u09be \u09aa\u09cd\u09b0\u09b8\u09c7\u09b8 \u0986\u0987\u09a1\u09bf \u09a6\u09cd\u09ac\u09be\u09b0\u09be \u09aa\u09cd\u09b0\u09b8\u09c7\u09b8\u0995\u09c7 \u099f\u09cd\u09b0\u09cd\u09af\u09be\u0995 \u0995\u09b0\u09c7\u0964 \u00a0 \u09aa\u09cd\u09b0\u09b8\u09c7\u09b8 \u09b6\u09c1\u09b0\u09c1 \u0995\u09b0\u09be \u09aa\u09cd\u09b0\u09b8\u09c7\u09b8 \u09b6\u09c1\u09b0\u09c1 \u09ac\u09be \u09b0\u09be\u09a8 \u0995\u09b0\u09be\u09a8\u09cb\u09b0 \u09b8\u09ae\u09df \u09a6\u09c1\u0987 \u09ad\u09be\u09ac\u09c7 \u0986\u09ae\u09b0\u09be \u098f\u099f\u09bf \u0995\u09b0\u09a4\u09c7 \u09aa\u09be\u09b0\u09bf, \u09ab\u09cb\u09b0\u0997\u09cd\u09b0\u09be\u0989\u09a8\u09cd\u09a1 \u09aa\u09cd\u09b0\u0995\u09cd\u09b0\u09bf\u09df\u09be\u09df \u0993 \u09ac\u09cd\u09af\u09be\u0995\u0997\u09cd\u09b0\u09be\u0989\u09a8\u09cd\u09a1 \u09aa\u09cd\u09b0\u0995\u09cd\u09b0\u09bf\u09df\u09be\u09df \u00a0 \u09ab\u09cb\u09b0\u0997\u09cd\u09b0\u09be\u0989\u09a8\u09cd\u09a1\u2026","rel":"","context":"In &quot;\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix&quot;","block_context":{"text":"\u09b2\u09bf\u09a8\u09be\u0995\u09cd\u09b8 \u098f\u09ac\u0982 \u0989\u09a8\u09bf\u0995\u09cd\u09b8 \u0964 Linux and Unix","link":"http:\/\/bangla.sitestree.com\/?cat=1231"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70059,"url":"http:\/\/bangla.sitestree.com\/?p=70059","url_meta":{"origin":70099,"position":3},"title":"PHP: How to Execute  Remote Scripts\/Services #16","author":"Author-Check- Article-or-Video","date":"August 24, 2021","format":false,"excerpt":"$url is the URL to execute$url = $_GET['url'];$file = fopen ($url, \"r\");if (!$file){echo \"Error.n\";}else{header('Content-Type: text\/xml');while (!feof ($file)){$line = fgets ($file, 1024);echo $line;}}fclose($file);How to pass information from JavaScript to PHP\/JSP - mix of PHP and JavaScript \/\/we are passing some value say 15 from JavaScript to PHPlocation.href=\"?xyz=15\"; fsockopen$fp = fsockopen(\"$urlToExecute\"); if\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":24412,"url":"http:\/\/bangla.sitestree.com\/?p=24412","url_meta":{"origin":70099,"position":4},"title":"Good Coding Style in PHP + Other languages #Root","author":"Author-Check- Article-or-Video","date":"April 8, 2021","format":false,"excerpt":"Style 1.1: Use proper indenting while ($x < $z) { if ($a == 1) { echo 'A was equal to 1'; } else { if ($b == 2) { \/\/do something } else { \/\/do something else } } } \u00a0 1.2 while ($x < $z) { if ($a ==\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":62819,"url":"http:\/\/bangla.sitestree.com\/?p=62819","url_meta":{"origin":70099,"position":5},"title":"Installing Guzzle #PHP","author":"Author-Check- Article-or-Video","date":"May 21, 2021","format":false,"excerpt":"\"Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.\" http:\/\/docs.guzzlephp.org\/en\/latest\/index.html And from my .bash_history, the installation process curl -sS https:\/\/getcomposer.org\/installer | php php composer.phar require guzzlehttp\/guzzle:~6.0 To Contribute to Guzzle: git clone https:\/\/github.com\/guzzle\/guzzle.git cd guzzle && curl -s\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70099","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70099"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70099\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70099"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}