简体   繁体   中英

curl_init and curl_setopt equivalent of ruby

What is the curl_init and curl_setopt equivalent of ruby?

$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);

I am using restclient.

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

But I am getting the error

RestClient::MethodNotAllowed (405 Method Not Allowed):

Can I use Rest-client. or should I need use some else. What is the equivalent of the php code

The error RestClient::MethodNotAllowed hints to the fact that the call method ( POST in your example) is not allowed on the server.

Make sure that the method you use in your client call is supported but the server for that URI.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM