腾讯官方微信域名检测接口,实时查询域名是否已被微信拦截

2020/9/30 8:03:46

本文主要是介绍腾讯官方微信域名检测接口,实时查询域名是否已被微信拦截,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

微信现在对外部链接的内容把控比较严格,可能一不小心链接就被封了,或者是被同行或者用户举报之类的。

那么这时候就要用到域名检测接口进行实时检测域名的状态是否被封,域名是否被拦截,这样才可以做好预防,不影响推广的效果。

在线使用:
接口地址:http://api.monkeyapi.com

请求方式:http get/post

返回格式:json

请求示例:http://api.monkeyapi.com?appkey=appkey&url=www.baidu.c

返回说明:

http://img4.sycdn.imooc.com/5f71a8a5000153b805540505.jpg

/// <summary>
        /// Http (GET/POST)
        /// </summary>
        /// <param name="url">请求URL</param>
        /// <param name="parameters">请求参数</param>
        /// <param name="method">请求方法</param>
        /// <returns>响应内容</returns>
        static string sendPost(string url, IDictionary<string, string> parameters, string method){            if (method.ToLower() == "post")
                {
                    HttpWebRequest req = null;
                    HttpWebResponse rsp = null;
                    System.IO.Stream reqStream = null;                try
                {
                    req = (HttpWebRequest)WebRequest.Create(url);
                    req.Method = method;
                    req.KeepAlive = false;
                    req.ProtocolVersion = HttpVersion.Version10;
                    req.Timeout = 60000;
                    req.ContentType = "application/x-www-form-urlencoded;charset=utf-8";                    byte[] postData = Encoding.UTF8.GetBytes(BuildQuery(parameters, "utf8"));
                    reqStream = req.GetRequestStream();
                    reqStream.Write(postData, 0, postData.Length);
                    rsp = (HttpWebResponse)req.GetResponse();
                    Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet);                    return GetResponseAsString(rsp, encoding);
                }                    catch (Exception ex)
                {                    return ex.Message;
                }                finally
                {                    if (reqStream != null) reqStream.Close();                    if (rsp != null) rsp.Close();
                }
            }            else
            {                //创建请求
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + "?" + BuildQuery(parameters, "utf8"));                //GET请求
                request.Method = "GET";
                request.ReadWriteTimeout = 5000;
                request.ContentType = "text/html;charset=UTF-8";
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream myResponseStream = response.GetResponseStream();
                StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));                //返回内容
                string retString = myStreamReader.ReadToEnd();                return retString;
            }
        }




这篇关于腾讯官方微信域名检测接口,实时查询域名是否已被微信拦截的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程