0
我想用auth.getMobileSession方法來驗證用last.fm REST api生成的last.fm應用程序的用戶。爲last.fm api創建authToken ruby
Last.fm說,對於移動應用,我們需要發送AuthToken
authToken (Required) : A 32-byte ASCII hexadecimal MD5 hash of the last.fm username and the user's password hash. i.e. md5(username + md5(password)), where '+' represents a concatenation. The username supplied should match the string used to generate the authToken.
這就是我想在紅寶石做:
password = Digest::MD5.hexdigest("my_password")
auth_token = Digest::MD5.hexdigest("#{user_name}#{password}")
url_with_params = URI.parse("#{url}?method=auth.getmobilesession&api_key=#{api_key}&username=#{user_name}&authtoken=#{auth_token}&api_sig=#{api_sig}&format=json")
resp = Net::HTTP.get_response(url_with_params)
puts JSON.parse(resp.body)
,我得到的輸出是:
{"error"=>4, "message"=>"Invalid authentication token. Please check username/password supplied"}
有人可以告訴我,我做錯了什麼?