c# - Implementing Last.fm authentication in Windows Phone 8 -
I have to implement last.fm authentication in my Windows Phone 8 app. Last.fm requires a POST request with https for a successful login. This is what I am doing.
public async zero GetMobileSession (string username, string password, action and lieutenance; LastFmAuthResponse & gt; onCompletion) {string CORE_URL = "https://ws.audioscrobbler.com/ 2.0 /"; Var parameter = new dictionary & lt; String, string & gt; (); Parameters.Add ("username", user name); Parameters.Add ("password", password); Parameters.Add ("method", "auth.getMobileSession"); Parameters.Add ("api_key", api_key); String sign = = get (parameter); String comboUrl = string.Concat ("method = auth.getMobileSession", "& amp; api_key =", api_key, "& user name =", user name, "and password =", password, "& api_sig = ", Signature); LastFmAuthResponse response = null; Byte [] pendingPostContent = encoding.UTF8.GetBytes (comboUrl); HttpWebRequest Request = (HttpWebRequest) WebRequest.Create (CORE_URL); request. Method = "post"; Request.ContentType = "application / x-www-form-urlencoded"; (Stream requeststream = awaiting request .Using GETRequestStreamAsync ()) {Wait for request. Stream Sync (pending post content, 0, pending post content. Lang); } Request.BeginGetResponse (New AsyncCallback (n = & gt; {HttpWebResponse rawResponse = (HttpWebResponse) request.EndGetResponse (n); string using rawData = string.Empty; (StreamReader Reader = New Stream Reader (rawResponse.GetResponseStream ()) } {RawData = Reader.ReadToEnd ();} {{string.IsNullOrEmpty (rawData)) {response = CommonFunctions.GetObjectFromString & lt; LastFmAuthResponse & gt; (rawData);}} End {response} on hold {})} ), tap; }
Although the code is failing on request.BeginGetResponse
, it states that the remote server can not be found, returns an error. Can anyone tell me what I am doing wrong here?
Comments
Post a Comment