Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[Function] Skype-Name?

hi there
a little snipped to check if skype exist, not used or invalid

Code
Private Function GetPageSource(ByVal URL As String)
      Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(URL)
      Dim response As System.Net.HttpWebResponse = request.GetResponse()
      Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())
      Dim sourcecode As String = sr.ReadToEnd()
      Return sourcecode
    End Function

Private Function CheckSkype(ByVal Skypename As String)
      Dim t As String = GetPageSource("https://login.skype.com/json/validator?new_username=" & Skypename)
      If t.Contains("status"":200") Then
      Return "error" 'not used skype name
      ElseIf t.Contains("status"":406") And Not t.Contains("Invalid Skype Name.") Then
      Return "exist" 'existing skype name
      ElseIf t.Contains("status"":406") And t.Contains("Invalid Skype Name.") Then
      Return "error2" 'invalid skype name
      End If
    End Function
This is a nice share, but there are a few ways that you can make it better. The first tip is, what is GetPageSource? I am assuming that it is another function, that isn't posted, that is a WebClient that gets the source of the page. It isn't needed. Another thing is that there is no Error Handling.

Here is how I would go about it.
Code
Private Function CheckSkype(ByVal Skype As String)
      Try
      Using WC As New Net.WebClient
            Dim Src As String = WC.DownloadString("https://login.skype.com/json/validator?new_username=" & Skype)
            If Src.Contains("status"":200") Then
            Return "Available"
            ElseIf Src.Contains("status"":406") And Not Src.Contains("Invalid Skype Name.") Then
            Return "Not Available"
            ElseIf Src.Contains("status"":406") And Src.Contains("Invalid Skype Name.") Then
            Return "Invalid"
            End If
      End Using
      Catch ex As Exception
      Return "Error: " & ex.ToString
      End Try
    End Function

Please note that I haven't tried this code, but I am pretty sure that it will work.
Why not extract the webheaders from a webrequest?

http://msdn.microsoft.com/en-us/library/....110).aspx
This is a great function,
However I believe it needs a little patching up in places.

Thanks for the share.
(Oct 3, 2014 09:01 AM)PatientZero Wrote:  This is a great function,
However I believe it needs a little patching up in places.

Thanks for the share.

A little? 🤣 i would say from scratch.
whoops sry i forgot to post my GetPageSource function :D
sorry i got it in the Function Region
(Oct 3, 2014 09:13 AM)TheBarret Wrote:  A little? 🤣 i would say from scratch.

It's alright,
It can do the job at least :P


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by FhackMar 2, 2022 03:52 AM 4 306 Mar 2, 2022 03:52 AM
Last Post: Fhack
[Python] by success = trueSep 14, 2013 07:05 PM 3 123 Sep 14, 2013 07:05 PM
Last Post: Dmaster_773
[C] by [Rn] 7s^2Sep 11, 2013 03:13 AM 5 187 Sep 11, 2013 03:13 AM
Last Post: g4143