Skip to content

Instantly share code, notes, and snippets.

@jaturken
Last active December 15, 2015 10:09
Show Gist options
  • Save jaturken/5243905 to your computer and use it in GitHub Desktop.
Save jaturken/5243905 to your computer and use it in GitHub Desktop.
check_share
def check_share?(url, uid)
# According to documentation from:
# http://api.mail.ru/docs/reference/rest/stream.getByAuthor/
request_url = "http://www.appsmail.ru/platform/api?" + request_params(url, uid)
responce = HTTParty.get(request_url)
end
private
def request_params(url, uid)
app_id = AppConfig.omniauth['moymir']['app_id']
secret_key = AppConfig.omniauth['moymir']['secret_key']
sig = Digest::MD5.hexdigest(params_for_sig(app_id, uid) + secret_key)
"method=stream.getByAuthor" +
"&secure=1" +
"&app_id=#{app_id}" +
"&uid=#{uid}" +
"&sig=#{sig}"
end
def params_for_sig(app_id, uid)
"app_id=#{app_id}" +
"method=stream.getByAuthor" +
"secure=1" +
"uid=#{uid}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment