I received error when trying to call single array from json_decode()
Undefined Index AccontNumber
And I have try to use Isset to the variable and doesnt get any result, Where do I doing wrong ?
$this->getToken();
$path = '/banking/v2/corporates/BCAAPI2016/accounts/0201245680/statements?StartDate=2016-09-01&EndDate=2016-09-01';
$method = 'GET';
$data = array();
$this->getSignature($path, $method, $data);
$headers = array(
'X-BCA-Key: '.self::$api_key,
'X-BCA-Timestamp: '.self::$timestamp,
'Authorization: Bearer '.self::$access_token,
'X-BCA-Signature: '.self::$signature,
'Content-Type: application/json',
'Origin: '.$_SERVER['SERVER_NAME']
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, self::$main_url.$path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPHEADER => $headers,
));
$output = curl_exec($ch); // This is API Response
curl_close($ch);
//this part I get error
$result = json_decode($output,true);
return view("bca.bca", [
"result" => $result
]);
my view
@if ($result['AccountDetailDataSuccess'])
@elseif ($result['AccountDetailDataFailed'])
@endif
and this the result if I var_dump($result)
array(2) { ["AccountDetailDataSuccess"]=> array(1) { [0]=> array(7) { ["AccountNumber"]=> string(10) "0201245680" ["Currency"]=> string(3) "IDR" ["Balance"]=> string(12) "118849999.53" ["AvailableBalance"]=> string(12) "118849999.53" ["FloatAmount"]=> string(4) "0.00" ["HoldAmount"]=> string(4) "0.00" ["Plafon"]=> string(4) "0.00" } } ["AccountDetailDataFailed"]=> array(0) { } }
How can I call just one single array from the JSON result ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire