如何解决尝试连接到 IGDB 的 API
我一直在尝试连接到学校项目的 API。我目前正在使用 Ruby。我正在尝试连接到 IGDB 的 API 并显示视频游戏,但我不能。除了错误,我什么也没得到。我有钥匙,但我无法连接到 API,甚至无法显示任何内容。任何能够帮助我建立联系的帮助将不胜感激。
require 'net/https'
POST https://api.igdb.com/v4/games
Client_ID = 'Client ID'
Authorization = 'Bearer + Access Token'
http = Net::HTTP.new('api.igdb.com/v4',443)
http.use_ssl = true
request = Net::HTTP::Post.new(URI('https://api.igdb.com/v4/games'),{'Client_ID' => 'Client ID','Authorization' => 'Bearer access_token'})
request.body = 'fields age_ratings,aggregated_rating,aggregated_rating_count,alternative_names,artworks,bundles,category,checksum,collection,cover,created_at,dlcs,expansions,external_games,first_release_date,follows,franchise,franchises,game_engines,game_modes,genres,hypes,involved_companies,keywords,multiplayer_modes,name,parent_game,platforms,player_perspectives,rating,rating_count,release_dates,screenshots,similar_games,slug,standalone_expansions,status,storyline,summary,tags,themes,total_rating,total_rating_count,updated_at,url,version_parent,version_title,videos,websites;'
puts http.request(request).body
错误:
(With POST https://api.igdb.com/v4/games)
C:\Users\Saad>Ruby Test2.rb
Test2.rb:2: unknown regexp options - ap
POST https://api.igdb.com/v4/games
(W/O the POST line)
C:\Users\Saad>Ruby test2.rb
Traceback (most recent call last):
9: from test2.rb:8:in `<main>'
8: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:1483:in `request'
7: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:932:in `start'
6: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
5: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:958:in `connect'
4: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
3: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
2: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
1: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `open'
C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `initialize': getaddrinfo: No such host is known. (SocketError)
9: from test2.rb:8:in `<main>'
8: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:1483:in `request'
7: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:932:in `start'
6: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:943:in `do_start'
5: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:958:in `connect'
4: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:105:in `timeout'
3: from C:/Ruby27-x64/lib/ruby/2.7.0/timeout.rb:95:in `block in timeout'
2: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `block in connect'
1: from C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `open'
C:/Ruby27-x64/lib/ruby/2.7.0/net/http.rb:960:in `initialize': Failed to open TCP connection to api.igdb.com/v4:443 (getaddrinfo: No such host is known. ) (SocketError)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。