【问题标题】:curl_init and curl_setopt equivalent of rubycurl_init 和 curl_setopt 相当于 ruby
【发布时间】:2014-07-24 11:27:28
【问题描述】:

ruby 的 curl_init 和 curl_setopt 等效项是什么?

$apikey='xxx';
$apisecret='xxx';
$nonce=time();
$uri='https://bittrex.com/api/v1.1/market/getopenorders?apikey='.$apikey.'&nonce='.$nonce;
$sign=hash_hmac('sha512',$uri,$apisecret);
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
$execResult = curl_exec($ch);
$obj = json_decode($execResult);

我正在使用restclient。

response = RestClient.post(uri, "sign" => sign, "Content-Type" => "application/x-www-form-urlencoded")

但我得到了错误

RestClient::MethodNotAllowed (405 Method Not Allowed):

我可以使用 Rest-client.还是我需要使用其他东西。 php代码相当于什么

【问题讨论】:

  • 也许应该是get,而不是post
  • @UriAgassi - 你能把这个添加为答案吗?我会接受的。

标签: php ruby-on-rails ruby ruby-on-rails-4 ruby-on-rails-3.2


【解决方案1】:

错误RestClient::MethodNotAllowed 暗示服务器上不允许调用方法(在您的示例中为POST)。

确保支持您在客户端调用中使用的方法,但支持该 URI 的服务器。

response = RestClient.get(uri, "sign" => sign, "Content-Type" => "application/x-www-form-urlencoded")

【讨论】:

    猜你喜欢
    • 2016-10-15
    • 1970-01-01
    • 1970-01-01
    • 2012-06-07
    • 2020-02-16
    • 2012-10-05
    • 2019-07-04
    • 2011-10-05
    • 2017-02-06
    相关资源
    最近更新 更多