- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
注意: How to use basic authorization in PHP curl对我不起作用。
正在尝试使用 Electrum,但我的访问似乎被拒绝了。 Electrum 与 php 脚本位于同一台服务器上。为了简化起见,我故意省略了钱包的任何命令。首先关注连接。
在终端中尝试 CURL 时
curl --data-binary '{"id":"curltext","method":"addrequest","params":{"amount":"3.14","memo":"test"}}' http://user:pass@127.0.0.1:7777
错误信息
curl: (7) Failed to connect to 127.0.0.1 port 7777: Connection refused
编辑:终端中的上述 CURL 命令现在可以使用了
PHP
$password = 'root';
$username = 'password';
$URL='http://127.0.0.1'; //Curl into own machine local ip is needed.
$port = 7777;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$result=curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); }
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
echo "<br>";
var_dump($result);
echo "<br>";
var_dump($status_code);
下面是我的错误
Error:
bool(false)
int(0)
下面是我的网络统计。端口已打开并正在监听。
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:7777 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
PHP7、PHP-CURL 和 CURL
安装在 linux Fedora 27 上。网络服务器类型 Apache 2.4
Electrum 3.1.2
curl -v 127.0.0.1 7777
返回:
Rebuilt URL to: 127.0.0.1/
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Wed, 04 Apr 2018 18:22:14 GMT
< Server: Apache/2.4.29 (Fedora)
< X-Powered-By: PHP/7.1.15
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=UTF-8
<
/*index.php code*/
* Connection #0 to host 127.0.0.1 left intact
* Rebuilt URL to: 7777/
* Trying 0.0.30.97...
* TCP_NODELAY set
* Immediate connect fail for 0.0.30.97: Invalid argument
* Closing connection 1
curl: (7) Couldn't connect to server
最佳答案
您需要另一个 curl 选项集:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
所以最后的顺序是:
$password = 'root';
$username = 'password';
$URL='http://127.0.0.1'; //Curl into own machine local ip is needed.
$port = 7777;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
$result=curl_exec($ch);
if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); }
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close ($ch);
echo "<br>";
var_dump($result);
echo "<br>";
var_dump($status_code);
关于php - 无法将 Curl-php 放入同一服务器 Electrum,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49599378/
我正在尝试制作一个支付验证系统,我在网上找到了 Electrum,现在正在尝试它,因为它有一个与 python 相关的控制台。我想要做的是:从一个充满 BTC 地址的文本文件中读取,然后搜索我自己在
我刚刚从 Electrum.org 的命令行安装了一个比特币钱包 这是我如何将它安装在我的用户帐户目录中../home/user/... sudo pip3 install https://downl
注意: How to use basic authorization in PHP curl对我不起作用。 正在尝试使用 Electrum,但我的访问似乎被拒绝了。 Electrum 与 php 脚本
我打开了 cmd 提示符(其环境变量中有 Python 2.7。 我使用 setup.py cd 到该文件夹,然后运行 python setup.py py2exe。 这应该会创建一个在 Wi
我是一名优秀的程序员,十分优秀!