Getting currency conversion data from Yahooapis now that iGoogle is gone

前端 未结 3 1663
孤街浪徒
孤街浪徒 2021-01-24 16:19

Up until yesterday I had a perfectly working budget organizer site/app working with iGoogle.

Through PHP, using the following little line

file_get_conten         


        
3条回答
  •  温柔的废话
    2021-01-24 17:07

    I created a routine to convert the currency based on @QuestionerNo27 http://jamhubsoftware.com/geoip/currencyconvertor.php?fromcur=USD&tocur=EUR&amount=1 you can consume this

        results->rate[$i]->Name; //<-- Get the name of the pair and turn it into a string (this looks like this: "USD to EUR").
        $rate = (string)$xml->results->rate[$i]->Rate; //<-- Do the same for the actual rate resulting from the conversion.
        $exchange[$name] = $rate; //<-- Put the data pairs into the array.
    endfor; //<-- End for loop. :)
    // ** WORK WITH EXCHANGE INFO ** //
    $conv = $fromcur . '/' . $tocur;
    $toeur = array( //<-- Create new array specific for conversion to one of the units needed.
             $tocur => $amt*$exchange[$conv], //<-- Create an array key for each unit used. In this case, in order to get the conversion of USD to EUR I ask for it from my $exchange array with the pair Name.
             $fromcur => $amt,
             "ex_amt" =>$amt*$exchange[$conv]); //<-- The way I coded the app, I found it more practical to also create a conversion for the unit into itself and simply use a 1, which translates into "do not convert"
    
    echo json_encode($toeur);
    
    ?>
    

提交回复
热议问题