2017-10-20 109 views
0

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

它总是返回此警告:

Warning: file_get_contents(localhost:3000/merchant/7c74bb77-4e25-4eea‌​-a9d3-df1cf6a9d218/…‌​) [function.file-get-contents]: failed to open stream:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

in C:\wamp\www\block\first.php on line 8

Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\block\first.php on line 8

+0

它总是返回:Warning:file_get_contents(http:// localhost:3000/merchant/7c74bb77-4e25-4eea-a9d3-d f1cf6a9d218/new_address?password = hasnisidra17&label = firsttym)[function.file-get-contents]:无法打开流:连接尝试失败,因为连接方在一段时间后没有正确响应,或者由于连接的主机没有回应。在第8行的C:\ wamp \ www \ block \ first.php上 致命错误:在第8行的C:\ wamp \ www \ block \ first.php中超过了30秒的最大执行时间 –

+0

将编辑这个问题,我可以看到在问题中有几个语法错误...在我的编辑被批准后(如果你愿意,你可以这样做),请确保这些错误不在你的实际代码中,然后编辑这个答案修复它们。 – JustCarty

回答

0

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

Don't forget to start the block chain service before you make the request

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; 
+0

关于调用未定义函数的geeting错误curl_init() –

+0

在您的系统上安装curl ...您可以在phpinfo – NID

+0

上检查它在本地主机上没有输出 –