Archive for the ‘Tutorials’ Category

XML-RPC in PHP :: FoXRate Currency Exchange API

Wednesday, October 21st, 2009

Today my friend Sakib was looking for a Currency Exchange API to implement it on one of his projects. So, I decided to write this small PHP code snippet for him. I hope this will help him and also other developers. Because, XML-RPC section of the PHP Manual is still incomplete :( .

<?php

/*
* Reference :: http://foxrate.org/
*
* For $from and $to :: http://www.oanda.com/site/help/iso_code.shtml
*/

function getExchangeRate($from = 'USD', $to = 'BDT', $ammount = 1.0) {

    $ammount = doubleval($ammount);
    $request = xmlrpc_encode_request("foxrate.currencyConvert", array($from, $to, $ammount));

    $stream = stream_context_create(array('http' => array(
        'method' => "POST",
        'header' => "Content-Type: text/xml\r\nUser-Agent: xmlrpclib.py/1.0  1 (by www.pythonware.com)\r\nHost: foxrate.org\r\n",
        'content' => $request
    )));

    $endpoint = "http://foxrate.org/rpc/";
    $file = file_get_contents($endpoint, false, $stream);
    $response = xmlrpc_decode($file);

    if (is_array($response) && xmlrpc_is_fault($response)) :
        return 'error';
    else :
        return $response;
    endif;
}

print_r(getExchangeRate());

?>

Making of a Joomla! 1.5 Module

Sunday, August 3rd, 2008

Parse error: syntax error, unexpected T_STRING in /home/vistaarc/public_html/wp-content/plugins/exec-php/includes/runtime.php(42) : eval()’d code on line 11

Avro Tutorial :: Part-1

Monday, June 4th, 2007

হঠাৎ করে মনে হলো আমাদের দেশী সফট্‌ওয়ার নিয়ে কিছু টিউটোরিয়াল লিখা উচিৎ। সে থেকেই এই লিখার অবতারণা। ওমিক্রণল্যাব ফোরামে প্রায়ই দেখা যায় সবাই ডিফল্ট সাইজে বাংলা লিখা পোষ্ট করেন। এতে অনেকেই পোষ্টগুলো ঠিকমতো পড়তে পারেন না। আমরা অভ্র কী-বোর্ডের ম্যাক্রো অপশন ব্যবহার করে সহজেই এর সমাধান করতে পারি।

Avro Tutorial :: Image-1
(more…)