There is a code on Php:
$timestamp = '1485942173' $api_key = '6t7a7c34914c0fa02f34b4b52d55aa2bb2f3b4b7'; $login = 'admin'; $phone = '79793665627'; $return = 'json'; $sender = 'admin'; $text = 'Hello!'; $params = array( 'timestamp' => $timestamp, 'login' => $login, 'phone' => $phone, 'text' => $text, 'sender' => $sender, 'return' => $return ); ksort( $params ); reset( $params ); $signature = md5( implode( $params ) . $api_key ); $query = "https://test.ru/get/send.php?login=" . $login . "&signature=" . $signature . "&phone=" . $phone . "&sender=" . $sender . "&return=" . $return . "×tamp=" . $timestamp . "&text=" . urlencode( $text ); $curl = curl_init(); curl_setopt( $curl, CURLOPT_URL, $query ); curl_setopt( $curl, CURLOPT_ENCODING, "utf-8" ); curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 120 ); curl_setopt( $curl, CURLOPT_TIMEOUT, 120 ); curl_setopt( $curl, CURLOPT_MAXREDIRS, 10 ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); $result = curl_exec( $curl ); I need a similar code on Ruby on Rails. I have already punched and Net::HTTP and OpenUri and Rest::Client answer is not the same as the Php request.
Last that punched:
timestamp = '1485942173' login = 'admin' sender = 'admin' format = 'json' client_phone = '79793665627' message = 'Hello!' params = { :login => login, :phone => client_phone, :return => format, :sender => sender, :text => message, :timestamp => timestamp } api_key = '6t7a7c34914c0fa02f34b4b52d55aa2bb2f3b4b7' params_string = params.values.join + api_key signature = Digest::MD5.hexdigest(params_string) query = "https://test.ru/get/send.php?login=" + login + "&signature=" + signature + "&phone=" + client_phone + "&sender=" + sender + "×tamp=" + timestamp + "&text=" + CGI.escape(message) uri = URI(query) res = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https', :verify_mode => OpenSSL::SSL::VERIFY_NONE) { |http| request = Net::HTTP::Get.new uri.request_uri response = http.request request resp = JSON.parse(response.body) }
URIfrom the standard library (which will itself screen the parameters), and not like you, self-made. - D-side