javascript验证实例

<script type="text/javascript" src="http://www.qiyeim.com/testpage/jquery-min.js"></script>
<script type="text/javascript">
var getParam = function(name){
    var search = document.location.search;
    var pattern = new RegExp("[?&]"+name+"\=([^&]+)", "g");
    var matcher = pattern.exec(search);
    var items = null;
    if(null != matcher){
        try{
            items = decodeURIComponent(decodeURIComponent(matcher[1]));
        }catch(e){
            try{
                items = decodeURIComponent(matcher[1]);
            }catch(e){
                items = matcher[1];
            }
        }
    }
    return decodeURI(items);
};

var domain="127.0.0.1:98";
var url="http://"+domain+"/api/redirect.html?op=check_token";//--接收数据的页面
url+="&UserName="+getParam('UserName');//包含中文的值,需要escape进行编码
url+="&Token="+getParam('Token');
url+="&callback=?";
url=encodeURI(url);
url=encodeURI(url);
jQuery.getJSON(url, function(data){
    switch (parseInt(data.msg)) {
    case 1:
        alert("验证成功!");
        break;
    case 2:
        alert("该帐号未登录,验证失败!");
        break;
    case 3:
        alert("该账号已被禁用!");
        break;
    case 4:
        alert("验证失败,令牌无效!");
        break;
    case 5:
        alert("该帐号不存在,验证失败!");
        break;
    default:
        alert("验证失败,令牌无效!");
        break;
    }
});
</script>

php验证实例

<?php
function Page_Load()
{
$domain="127.0.0.1:98";   //触点通服务端ip地址
$ch = curl_init();
$url = "http://".$domain."/api/redirect.html?op=check_token&UserName=".urldecode($_GET['UserName'])."&Token=".urldecode($_GET['Token']);
$url=urldecode($url);
$url=urldecode($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec($ch);
echo "结果:".$output."<br>";
curl_close ($ch);
switch($output)
   {
   case "({msg:1})":
          echo "验证成功!";
          break;
   case "({msg:2})":
          echo "该帐号未登录,验证失败!";
          break;
   case "({msg:3})":
          echo "该账号已被禁用!";
          break;
   case "({msg:4})":
          echo "验证失败,令牌无效!";
          break;
   case "({msg:5})":
          echo "该帐号不存在,验证失败!";
          break;
   default:
          echo "验证失败,令牌无效";
   }

}
if($_GET['UserName'] || $_GET['Token'])
{
    Page_Load();
}
?>

ASP.NET验证实例

<%
protected void Page_Load(object sender, EventArgs e)
{
    string domain = "127.0.0.1:98";
    System.Net.WebClient wc = new System.Net.WebClient();
    string url = "http://" + domain + "/api/redirect.html?op=check_token&UserName=" + HttpUtility.UrlEncode(Request.QueryString["UserName"]) + "&Token=" + HttpUtility.UrlEncode(Request.QueryString["Token"]);
url = HttpUtility.UrlEncode(url);
url = HttpUtility.UrlEncode(url);
    byte[] bt = wc.DownloadData(url);
    string result = System.Text.Encoding.Default.GetString(bt);

    Response.Write("结果:" + result + "<br>");
    switch (result)
    {
        case "({msg:1})":
            Response.Write("验证成功!");
            break;
        case "({msg:2})":
            Response.Write("该帐号未登录,验证失败!");
            break;
        case "({msg:3})":
            Response.Write("该账号已被禁用!");
            break;
        case "({msg:4})":
            Response.Write("验证失败,令牌无效!");
            break;
        case "({msg:5})":
            Response.Write("该帐号不存在,验证失败!");
            break;
        default:
            Response.Write("验证失败,令牌无效");
            break;
    }
}
%>

示例代码下载