【问题标题】:generate new address for blockchain wallet为区块链钱包生成新地址
【发布时间】:2018-04-01 13:22:48
【问题描述】:

我正在使用区块链 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 中

致命错误:C:\wamp\www\block\first.php 第 8 行的最大执行时间超过 30 秒

【问题讨论】:

  • 它总是返回:警告: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 秒的最大执行时间
  • 提交了对问题的编辑后,我可以看到问题中有几个语法错误...在我的编辑被批准后(如果您愿意,您可以这样做),请确保这些错误不在您的实际代码中,然后编辑此答案以修复它们。

标签: php blockchain


【解决方案1】:

您可能想这样尝试:我一直在使用它来获取新地址

在发出请求之前不要忘记启动区块链服务

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;

【讨论】:

  • 关于调用未定义函数 curl_init() 的接收错误
  • 在你的系统上安装 curl...你可以在 phpinfo 上查看
  • 在本地主机上没有输出
  • 它给出空白页
  • 尝试直接浏览url看是否返回地址
猜你喜欢
  • 2022-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-17
  • 1970-01-01
  • 2022-11-22
  • 2019-11-15
  • 1970-01-01
相关资源
最近更新 更多