Skype username validation

家住魔仙堡 提交于 2019-12-18 16:52:42

问题


Is there a way to validate that a Skype username is valid in a web app? (form validation upon account creation)

By valid I do not mean by using regular expressions. We an easily check to see if it is 6-22 characters, starts with a letter, etc. I want to verify that either 1) the username entered actually calls the user inputting it, similar to when we validate email by sending an email with a link to verify it or 2) verify that there exists in the Skype database a user with that username.

Thanks!


回答1:


I guess you'll have to do exactly what you said: “similar to when we validate email by sending an email with a link to verify it”

I'd dig into Skype4py, you'll find an example of searching for someone.

So you can do:

  1. some kind of early validation by searching for that person
  2. sending him/her a txt message with a key/link to verify your user

See: need an python script that uses skype4py to send an instant message




回答2:


This may not be very reliable, but the following endpoint will give you different responses based on the availability of a Skype username: https://login.skype.com/json/validator. Here are two examples of (at the time of this writing) an unavailable and available username:

# Request (unavailable):
curl -iX POST -H" Application/json" https://login.skype.com/json/validator?new_username=borist

# Response:
{
  "status": 406,
  "status_text": "valid",
  "data": {
    "markup": "Skype Name not available",
    "alternatives": true,
    "fieldDetails": "<label>Suggestions<\/label><ul><li><label><input class=\"skypeNameSuggestion\" type=\"radio\" name=\"selectSkypeName\" value=\"borist92\"\/>borist92<\/label> <\/li><li><label><input class=\"skypeNameSuggestion\" type=\"radio\" name=\"selectSkypeName\" value=\"borist176\"\/>borist176<\/label> <\/li><li><label><input class=\"skypeNameSuggestion\" type=\"radio\" name=\"selectSkypeName\" value=\"borist417\"\/>borist417<\/label> <\/li><\/ul>"
  }
}

# Request (available)
curl -iX POST -H" Application/json" https://login.skype.com/json/validator?new_username=boris3294a

# Response 
{
  "status":200,
  "status_text":"valid",
  "data":{"markup":"",
  "alternatives":false,
  "fieldDetails":""}
}



回答3:


Building off of pho79's answer, I have made a gist. The code simply checks to see if the message returned says that the name is unavailable meaning that it is in use. There are some other messages it sends back for other errors, so this is what I went with.

import requests

def checkName(name):
    values = { "new_username" : name }
    r = requests.post("https://login.skype.com/json/validator", values)
    return "not available" in r.json()[u'data'][u'markup']


来源:https://stackoverflow.com/questions/8951625/skype-username-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!