下面是我的代码,我需要从 beow API 请求中获取 account_name 的值,请仔细阅读并提出建议。我需要获得的唯一值是account_name值。请帮忙谢谢
$curl = curl_init();
switch ($method){
case "POST":
curl_setopt($curl, CURLOPT_POST, 1);
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
case "PUT":
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
if ($data)
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
break;
default:
if ($data)
$url = sprintf("%s?%s", $url, http_build_query($data));
}
// OPTIONS:
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"authorization: Bearer sk_test_df78c3c2d08ea1f266b8b19524a249e77c0eaa14",
"content-type: application/json",
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
// EXECUTE:
$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
return $result;
}
$bank="033";
$accno=2056194452;
$get_data = callAPI('GET', 'https://api.paystack.co/bank/resolve?account_number='.$accno.'&bank_code='.urlencode($bank), false);
$response = json_decode(json_encode($get_data), true);
echo $response;````
#Result of code will output the below:#
`{ "status": true, "message": "Account number resolved", "data": { "account_number": "2056194452", "account_name": "OLADEPO WISDOM IBRAHIM", "bank_id": 18 } }`
倚天杖