-3

The code is https://www.livecoin.net/api/examples#vb

I tried to add closing bracket at netbean and I got a warning unnecessary closing bracket. What am I missing?

<?php

$url = "https://api.livecoin.net/exchange/buylimit";
$apiKey = "gJx7Wa7qXkPtmTAaK3ADCtr6m5rCYYMy";
$secretKey = "8eLps29wsXszNyEhOl9w8dxsOsM2lTzg";

$params = array(
    'currencyPair'=> 'BTC/USD',
    'price'=> 60,
    'quantity'=>1
);

ksort($params);
$postFields = http_build_query($params, '', '&');
$signature = strtoupper(hash_hmac('sha256', $postFields, $secretKey));

$headers = array(
    "Api-Key: $apiKey",
    "Sign: $signature"
);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 'POST');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($statusCode!=200) {
    //dump info:
    echo "Status code: $statusCode, response: $response";
    //throw new Exception('Can not execute the query!');
}

var_dump(json_decode($response));
user4951
  • 32,206
  • 53
  • 172
  • 282
  • 2
    It's common not to close the PHP tag if there is no raw HTML. In fact, [it's in the Zend style guide not to do so](https://framework.zend.com/manual/1.11/en/coding-standard.coding-style.html). – Phylogenesis Nov 06 '17 at 14:36
  • 2
    PHP closes it's last block itself. No need for that. It's only nessessary if you want to add another block (php or html, and so on) – Joshua K Nov 06 '17 at 14:36

1 Answers1

0

The PHP ?> closing is not needed when in that specific file you write only PHP code, closing PHP, in that case, is just a waste of performance.

Fabio Carpinato
  • 1,121
  • 6
  • 13