这段代码有什么问题?
不知道为什么,但格式在这里搞砸了。这是行:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
我是新来的,所有的帮助都得到了赞赏。谢谢。
<?php
if(isset($_POST['payment'])){
require('config.php');
$ch= curl_init('https://coinbase.com/api/v1/account/generate_receive_address');
$amount=$_POST['amount'];
$json=json_encode(array("api_key"=>COINBASE_APIKEY,"address"=>array("callback_url"=>$_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']).'callback.php')));
curl_setopt($ch, CURLOPT_HTTPHEADERS, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_POST, 1);
$jsonreturn=json_decode(curl_exec($ch),true);
if(is_integer($amount) && $amount>0 && $jsonreturn['callback_url']==$_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']).'callback.php'){
$mysql=new mysqli(MYSQL_HOSTNAME,MYSQL_USERNAME,MYSQL_PASSWORD,MYSQL_DATABASE);
$mysql->query("INSERT INTO invoices(Amount, Address) VALUES ('$amount','".$jsonreturn['address']."')");
$mysql->close();
header('refresh: 1;url=payment.php?address='.$jsonreturn['address'].'&amount='.$amount);
exit();
}else{
header("refresh: url=payment.php?error=1");
exit();
}
}
?>