这是我的代码
<?php
include("connect.php");
$bc = $dbh->prepare("SELECT * FROM `blockchain`");
$bc->execute();
$bcs = $bc->fetch(PDO::FETCH_ASSOC);
$type = $_REQUEST['type'];
$price = $_REQUEST['amount'];
$uid = $_REQUEST['uid'];
$secret = $bcs['apikey'];
$my_address = $bcs['badd'];
$my_callback_url = 'http://www.imusicsong.com/api/bcp.php?secret='.$secret;
$root_url = 'https://blockchain.info/api/receive';
$parameters = 'method=create&address=' . $my_address .'&callback='. urlencode($my_callback_url);
$response = file_get_contents($root_url . '?' . $parameters);
$object = json_decode($response);
$stmt = $dbh->prepare("INSERT INTO `orders` (`uid`, `processor`, `type`, `date`, `price`) VALUES (:uid, 'bitcoin', :type, '".date("Y-m-d")."', :price)");
$stmt->execute(array(":uid" => $uid, ":type" => $type, ":price" => $price));
echo 'Send Payment in the amount of '.$price.' BTC To Bitcoin Address : ' . $object->input_address;
?>
这是从他们自己的api代码派生的https://blockchain.info/api/api_receive
一切都设置正确,但我收到以下错误
Warning: file_get_contents(https://blockchain.info/api/receive?method=create&address=yourbitcoinaddress&callback=http://www.imusicsong.com/api/bcp.php?secret=replacewithbcapi): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in C:\wamp\www\music\bc.php on line 23
如果我将该网址复制并粘贴到我的浏览器中,它会加载,但它会向我显示错误Error You Must Provide a Destination Address
如果我在该链接中将所有&
更改回&
,则会加载json response
{"callback_url":"http:\/\/www.imusicsong.com\/api\/bcp.php?secret=replacewithbcapi","input_address":"16uEPhaC5B5v6xLKem4hDoQRE11yZ4nEc4","destination":"1McVCZZrUgtkrUMkqfTF8kaaSSQBg54Fkd","fee_percent":0}
因此,我不仅不知道它为什么会给我这个错误,即使它没有抛出那个错误的事实是通过&
而不是&
传递网址的事实导致他们的系统无法通过正确的响应。
所以我需要确定如何解决这两个问题。
1。)为什么file_get_contents
没有打开网址
2.。)如何file_get_contents
不将&
更改为&