I'm a bit confused on how to handle this. Essentially I'm trying to learn more about Angular on Rails, so I'm using Rails in API Mode - However, currently, I'm trying to build an API into the non-API version of Rails I initiated (Not quite relevant, but I'm curious how to get it to work for both).
Very basic test off the bat, I'd like to his
/steam/:id
endpoint (in this example) and get the return for
GetPlayedSummaries
. HTTParty is installed, and working in terminal.
class SteamController < ApplicationController
@steamKey = "{REDACTED}"
@baseUrl = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='+@steamKey+'&steamids='+@steamId+'"
def get_player_summaries
@steamId = params[:id]
puts @baseUrl
@games = HTTParty.get(@baseUrl).to_json
puts response.body, response.code, response.message, response.headers.inspect
end
end
This is my very basic controller. Realistically I have no reason to have steamKey separated but it helps encourage where I need help.
Originally I had @baseUrl
as
@baseUrl = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=#{@steamKey}+'&steamids=#{@steamId}"
With the full version I get a bad argument (expected URI object or URI string)
pointing at the @baseUrl so I feel like I'm not including it properly. I'm working on that but even once it works I'm not quite sure how to make it so it just throws it out into the UI as pure JSON? I have this done with a lot of my other elements using JSON Builders etc, but that's DB Data. This is just an API call.
Insight/documents I can check out?
EDIT: I believe my issue regarding using @steamKey
is related to This SO Article. @
is even being passed down to get_player_summaries