我正在尝试通过php curl获取一些信息。在我的localhost wamp环境中,它工作得很好,但是当我在服务器上在线上传它时,它说:-
400 Bad Request
nginx/1.9.12
这是我的代码:-
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.blockcypher.com/v1/eth/main/addrs?token=some_token")
curl_setopt($ch, CURLOPT_POST, 1);
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);
在API文档中,我看不到将令牌放入POST请求的查询中的任何内容。
因此,我检查了您的代码,但是将令牌作为发布字段,并且可以正常工作:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.blockcypher.com/v1/eth/main/addrs");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'token=some-token-here');
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);
docs:https : //dev.blockcypher.com/? javascript#generate-address- endpoint
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句