i trying make php script use new site called oanda , trade virtual money on forex market.
i trying convert command line code in php:
$curl -x post -d "instrument=eur_usd&units=1000&side=buy&type=market" https://api-fxpractice.oanda.com/v1/accounts/6531071/orders
if can give source code or explain -x post
, -d
mean , how convert them php awesome.
thank help!
// create new curl resource $ch = curl_init(); // set url , other appropriate options $defaults = array( curlopt_url => 'https://api-fxpractice.oanda.com/v1/accounts/6531071/orders', curlopt_post => true, curlopt_postfields => "instrument=eur_usd&units=1000&side=buy&type=market"); curl_setopt_array($ch, $defaults); // grab url , pass browser $exec = curl_exec($ch); // close curl resource, , free system resources curl_close($ch); if ($exec) { print_r($exec); //print results }
and answer question:
curl -
x post
implies http post request,-d
parameter (long version:--data
) tells curl follows post parameters
if want more information, can find here: curl functions , here: manual -- curl usage explained
Comments
Post a Comment