背景故事:基本上我正在尝试制作BTC api&要做到这一点,我需要基本上使用($ custom in it),因为我需要将变量$ _SESSION ['username']解析到我的回调文件中以验证用户。我真的被困在这里了。
function getAddress($address, $callback, $_SESSION["username"], $secret)
{
$username = $_SESSION['username'];
$root_url = 'https://blockchain.info/api/receive';
$parameters = 'method=create&address=' . $address .'&callback='. urlencode($callback);
$callback = $callback.'?custom='.$username.'&secret='.$secret;
$response = file_get_contents($root_url . '?' . $parameters);
$object = json_decode($response);
return $object->input_address;
}
我知道我不能只把变量$ _SESSION ['username']放在那里,我不是100%肯定如何做到这一点:回调文件:
$confirmation_level = 4;
$real_secret = 'ZzsMLGKe162CfA5EcG6j'; //Your Secret Key
$address = 'address'; //Your Bitcoin Address
$username = $_GET['custom'];
$input_address = $_GET['input_address'];
$transaction_hash = $_GET['transaction_hash'];
$input_transaction_hash = $_GET['input_transaction_hash'];
$value_in_satoshi = $_GET['value'];
$value_in_btc = $value_in_satoshi / 100000000;
//skipping to validate part
$btcpaidupdate = $odb ->prepare("UPDATE `users` SET paid=1 WHERE `username` = '$username'");
$btcpaidupdate ->execute();
因此,您可以看到我完全停留在如何将实际变量解析为回调api文件。