Can someone possibly tell me what's wrong with this? I've never tried to post multidim array over curl/php, any help would be mega appreciated.
Getting bad response from server, I think they're getting some of the data but their response isn't helpful. Trying to build on their code, so they won't help with this kind of thing. (it's not against their TOS, it's just something they don't support)
Also, I know the cookie files/auth are working because I do this on another function just fine, except that one isn't multidimensional.
$post_data = array (
'tradeOrder' => array (
'FirstOrder' => array (
'Legs' => array (
'Id' => '0',
'SecurityId' => '643',
'SecurityName' => 'AAPL',
'SecurityExchange' => 'NASDAQ national market',
'Side' => 'Buy',
'Quantity' => '100'
),
'SymbolLastPrice' => '93.72',
'Price' => '93.75',
'StopPrice' => '0.01',
'Type' => 'Limit',
'TimeInForce' => 'Day',
'AllOrNone' => 'false',
'Exchange' => 'AUTO',
'TrailingAmount' => '0.01',
'TrailingAmountType' => 'Absolute',
'LimitOffset' => '0',
'LimitOffsetType' => 'Absolute',
'IsTrailingVisible' => 'false',
'IsLimitOffsetVisible' => 'false',
'IsTrailingAmountAbsolute' => 'true',
'IsLimitOffsetAbsolute' => 'true',
'ExecutionTarget' => 'New',
),
'AdvancedOrderType' => 'Simple',
'IsAdvancedOrder' => 'false'
)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://demo-trading.just2trade.com/TradeTicket/PlaceOrder");
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
//curl_setopt($ch, CURLOPT_HEADER, true);
//curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $result_array['access_token']]);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
curl_setopt($ch, CURLOPT_ENCODING,'gzip');
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
Forms I'm trying to post as follows
{
"tradeOrder": {
"FirstOrder": {
"Legs": [{
"Id": 0,
"SecurityId": 643,
"SecurityName": "AAPL",
"SecurityExchange": "NASDAQ national market",
"Side": "Buy",
"Quantity": 100
}],
"SymbolLastPrice": 93.72,
"Price": 93.72,
"StopPrice": 0.01,
"Type": "Limit",
"TimeInForce": "Day",
"AllOrNone": false,
"Exchange": "AUTO",
"TrailingAmount": 0.01,
"TrailingAmountType": "Absolute",
"LimitOffset": 0,
"LimitOffsetType": "Absolute",
"IsTrailingVisible": false,
"IsLimitOffsetVisible": false,
"IsTrailingAmountAbsolute": true,
"IsLimitOffsetAbsolute": true,
"ExecutionTarget": "New"
},
"AdvancedOrderType": "Simple",
"IsAdvancedOrder": false
}
}