예제 #1
0
    //Check to see that OandaWrap is setup correctly.
    //Arg1 can be 'Demo', 'Live', or Sandbox;
    if (OandaWrap::setup('Demo', $apiKey, $accountId) === FALSE) {
        throw new Exception('contact Tavurth@gmail.com to submit a bug report.');
    }
    //Html initiation
    echo '<html>';
    echo '<body>';
    //Style our body
    echo '<style> 
	
		body { font-size: 18px; color:#222222; }
		p { position:relative; left:10%; margin: 0; padding: 0; } 
		p.indent { position:relative; left:30%; }
	
	</style>';
    //Our header
    echo '<p><h2>OandaWrap quotes test:</h2></p>';
    //Save the requested pairs as an array
    $pairs = array('EUR_USD', 'EUR_AUD', 'EUR_JPY', 'EUR_CAD');
    //Loop through the array
    foreach ($pairs as $pair) {
        //Check for valid quote
        if ($quote = OandaWrap::price($pair)) {
            echo '<p>Price of ' . $pair . ' is: </p><p class="indent"> ' . $quote->bid . ' => ' . $quote->ask . '</p>';
        }
    }
    //End the html
    echo '</body>';
    echo '</html>';
}