Skip to content

Commit 682f034

Browse files
committed
adding autosuggest quickstart
1 parent ce27769 commit 682f034

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ruby/Search/BingAutosuggestv7.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
require 'net/https'
2+
require 'uri'
3+
require 'json'
4+
5+
# **********************************************
6+
# *** Update or verify the following values. ***
7+
# **********************************************
8+
9+
# Replace the subscriptionKey string value with your valid subscription key.
10+
subscriptionKey = 'enter key here'
11+
12+
host = 'https://api.cognitive.microsoft.com'
13+
path = '/bing/v7.0/Suggestions'
14+
15+
mkt = 'en-US'
16+
query = 'sail'
17+
18+
params = '?mkt=' + mkt + '&q=' + query
19+
uri = URI (host + path + params)
20+
21+
request = Net::HTTP::Get.new(uri)
22+
request['Ocp-Apim-Subscription-Key'] = subscriptionKey
23+
24+
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
25+
http.request (request)
26+
end
27+
28+
puts JSON::pretty_generate (JSON (response.body))

0 commit comments

Comments
 (0)