我正在使用区块链API为每个钱包生成一个新地址 这是代码:
<?php
$guid = "7c74bb77-4e25-4eea-a9d3-df1cf6a9d218";
$main_password = "******";
$label = "firsttym";
$json_url = "http://localhost:3000/merchant/$guid/new_address?
password = $main_password & label = $label";
$json_data = file_get_contents($json_url);
$json_feed = json_decode($json_data ,true);
$message = $json_feed->message;
$txid = $json_feed->tx_hash;
?>
它总是返回此警告:
警告:file_get_contents(localhost:3000 / merchant / 7c74bb77-4e25-4eea -a9d3-df1cf6a9d218 / ...)[function.file-get-contents]:无法打开流:
连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机无法响应。在第8行的C:\ wamp \ www \ block \ first.php
致命错误:第8行的C:\ wamp \ www \ block \ first.php超出了30秒的最长执行时间
答案 0 :(得分:0)
您可能想要这样尝试:我一直在使用它来获取新地址
在发出请求之前,不要忘记启动区块链服务
blockchain-wallet-service start --port 3000
$url = "http://localhost:3000/merchant/$guid/new_address?password=$password&label=$label";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$data = json_decode(curl_exec($ch), TRUE);
return $data;