Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official FoxESS API Documentation #170

Open
gabrielborel opened this issue May 8, 2023 · 4 comments
Open

Official FoxESS API Documentation #170

gabrielborel opened this issue May 8, 2023 · 4 comments

Comments

@gabrielborel
Copy link

gabrielborel commented May 8, 2023

Hello Everyone!

Does anyone have the latest Official FoxESS API Documentation?

I have already download one from this issue #74, but, when I call any resource with POST method I receive status 405 Not Allowed, if I call any resource with GET method I receive status 200 and HTML content, in the pdf says that the doc is updated at 02-2022, the API has changed? There is some way that I can get the latest version?

Thanks everybody.

@phoet
Copy link

phoet commented Oct 7, 2024

yeah, i have the same issue

@FozzieUK
Copy link
Collaborator

FozzieUK commented Oct 7, 2024

The old Fox API has been made private, you now have to use the new OpenAPI which you can find documented here https://www.foxesscloud.com/public/i18n/en/OpenApiDocument.html

@phoet
Copy link

phoet commented Oct 7, 2024

yeah, looks like i was on a wrong endpoint.

do you know if there is any way to debug the signature creation?

i get a {"errno":40256,"msg":"Parameter could not be parsed correctly illegal signature"}

this is my code

require 'net/http'
require 'uri'
require 'digest/md5'
require 'json'

host = "https://www.foxesscloud.com"
token = "your-own-token"
timestamp = Time.now.to_i * 1000
lang = "en"
path = "/op/v0/plant/list"
puts signature = "#{path}\r\n#{token}\r\n#{timestamp}"
puts signature = Digest::MD5.hexdigest(signature.encode('UTF-8'))

uri = URI("#{host}#{path}")
req = Net::HTTP::Post.new(uri)
req['token'] = token
req['timestamp'] = timestamp
req['lang'] = lang
req['signature'] = signature

Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  response = http.request(req)
  puts response.body
end

maybe someone can give me a valid input output example so that i can verify the pieces

@phoet
Copy link

phoet commented Oct 7, 2024

i found the issue, the signature is literally using the carriage return, so it needs to be escaped such as

require 'net/http'
require 'uri'
require 'digest/md5'
require 'json'

host = "https://www.foxesscloud.com"
token = "your-own-token"
timestamp = Time.now.to_i * 1000
lang = "en"
path = "/op/v0/plant/list"
puts signature = "#{path}\\r\\n#{token}\\r\\n#{timestamp}"
puts signature = Digest::MD5.hexdigest(signature.encode('UTF-8'))

uri = URI("#{host}#{path}")
req = Net::HTTP::Post.new(uri)
req['token'] = token
req['timestamp'] = timestamp
req['lang'] = lang
req['signature'] = signature

Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  response = http.request(req)
  puts response.body
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants