一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

eoLinker-API Shop IP地址查詢 C#調(diào)用示例代碼

 eoLinker 2018-02-27

IP地址查詢

根據(jù)IP地址或者域名,查詢?cè)?/span>IP所屬的區(qū)域  

該產(chǎn)品擁有以下APIs

1.          查詢IP信息

注意,該示例代碼僅適用于 www. 網(wǎng)站下API 使用該產(chǎn)品前,您需要通過 https://www./#/api/detail/?productID=118 申請(qǐng)API服務(wù)


1.查詢IP信息

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using System.Web.Script.Serialization;

namespace apishop_sdk
{
    class Program
    {
        /**
         * 轉(zhuǎn)發(fā)請(qǐng)求到目的主機(jī)
         * @param method string 請(qǐng)求方法
         * @param url string 請(qǐng)求地址
         * @param params Dictionary<string,string> 請(qǐng)求參數(shù)
         * @param headers Dictionary<string,string> 請(qǐng)求頭
         * @return string
         **/
        static string apishop_send_request(string method, string url, Dictionary<string, string> param, Dictionary<string, string> headers)
        {
            string result = string.Empty;
            try
            {
                string paramData = "";
                if (param != null && param.Count > 0)
                {
                    StringBuilder sbuilder = new StringBuilder();
                    foreach (var item in param)
                    {
                        if (sbuilder.Length > 0)
                        {
                            sbuilder.Append("&");
                        }
                        sbuilder.Append(item.Key + "=" + item.Value);
                    }
                    paramData = sbuilder.ToString();
                }
                method = method.ToUpper();
                if (method == "GET")
                {
                    url = string.Format("{0}?{1}", url, paramData);
                }
                HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create(url);
                if (method == "GET")
                {
                    wbRequest.Method = "GET";
                }
                else if (method == "POST")
                {
                    wbRequest.Method = "POST";
                    wbRequest.ContentType = "application/x-www-form-urlencoded";
                    wbRequest.ContentLength = Encoding.UTF8.GetByteCount(paramData);
                    using (Stream requestStream = wbRequest.GetRequestStream())
                    {
                        using (StreamWriter swrite = new StreamWriter(requestStream))
                        {
                            swrite.Write(paramData);
                        }
                    }
                }

                HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse();
                using (Stream responseStream = wbResponse.GetResponseStream())
                {
                    using (StreamReader sread = new StreamReader(responseStream))
                    {
                        result = sread.ReadToEnd();
                    }
                }
            }
            catch
            {
                return "";
            }
            return result;
        }

        class Response
        {
            public string statusCode;
        }
       
        static void Main(string[] args)
        {
            string method = "POST";
            string url = "https://api./common/ip/queryIPInfo";
            Dictionary<string, string> param = new Dictionary<string, string>();           
            param.Add("ip", ""); //ip地址    
       
            Dictionary<string, string> headers = null;
            string result = apishop_send_request(method, url, param, headers);
            if (result == "")
            {
                //返回內(nèi)容異常,發(fā)送請(qǐng)求失敗
                Console.WriteLine("發(fā)送請(qǐng)求失敗");
                return;
            }

            Response res = new JavaScriptSerializer().Deserialize<Response>(result);
            if (res.statusCode == "000000")
            {
                //狀態(tài)碼為000000, 說明請(qǐng)求成功
                Console.WriteLine(string.Format("請(qǐng)求成功: {0}", result));
            }
            else
            {
                //狀態(tài)碼非000000, 說明請(qǐng)求失敗
                Console.WriteLine(string.Format("請(qǐng)求失敗: {0}", result));
            }
            Console.ReadLine();
        }
    }
}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多

    人妻乱近亲奸中文字幕| 日韩国产精品激情一区| 欧洲一级片一区二区三区| 亚洲中文字幕视频在线播放| 中文人妻精品一区二区三区四区 | 99精品国产一区二区青青| 午夜视频免费观看成人| 99久久国产综合精品二区| 99亚洲综合精品成人网色播 | 九九热视频免费在线视频| 五月婷日韩中文字幕四虎| 午夜视频在线观看日韩| 日本和亚洲的香蕉视频| 亚洲二区欧美一区二区 | 欧美三级精品在线观看| 超薄肉色丝袜脚一区二区| 日韩一区二区三区有码| 欧美同性视频免费观看| 日韩一级欧美一级久久| 成人午夜激情在线免费观看| 欧美一区二区三区视频区| 国产老女人性生活视频| 精品欧美国产一二三区| 四季精品人妻av一区二区三区| 正在播放国产又粗又长| 精品一区二区三区中文字幕| 亚洲国产四季欧美一区| 亚洲专区一区中文字幕| 国产精品亚洲综合天堂夜夜| 亚洲一区二区三在线播放| 黄片免费在线观看日韩| 草草视频福利在线观看| 亚洲一区二区三区在线免费| 中国一区二区三区不卡| 中国美女偷拍福利视频| 国产亚洲成av人在线观看 | 一二区中文字幕在线观看| 国产日韩综合一区在线观看| 偷拍偷窥女厕一区二区视频| 日本午夜一本久久久综合| 97人妻精品免费一区二区|