收到错误消息“无法连接到live.stellar.org端口9002” - PHP CURL

时间:2015-03-23 02:28:41

标签: php curl

我收到了这条消息。

  

无法连接到live.stellar.org端口9002:连接超时

我的代码是,请帮助我。

$fields = array(
    'method' => 'account_tx',
    'params' => array(
        array(
        'account' => 'gPP3hmC86rA8aJiCwRLXRLd9NxGnL2qSwG',
        'limit' => '20'
        )
        )
);

$data = json_encode($fields);
$response = curl_post($data);

function curl_post($fields)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://live.stellar.org:9002");
    //curl_setopt($ch, CURLOPT_PORT , 9002);
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec ($ch);
    echo curl_error($ch);
    curl_close ($ch); 
    return $response;
}

这是来自Stellar的API代码:

curl -X POST https://live.stellar.org:9002 -d '
{
  "method": "account_tx",
  "params": [
    {
      "account": "gPP3hmC86rA8aJiCwRLXRLd9NxGnL2qSwG",
      "limit": 4
    }
  ]
}'

1 个答案:

答案 0 :(得分:-1)

一切都是对的。

所以,可能性是:

  1. 也许您的服务器IP在该网站上被禁止;
  2. 可能防火墙阻止您访问此主机/端口;
  3. 也许您需要延长超时时间。
  4. 在其他主机上试用此代码或在本地运行以确保。