public IPLocation ParaseString(string _content, IPLocation _iplocation) { JavaScriptSerializer j = new JavaScriptSerializer(); IPLocation Iplocation = new IPLocation(); Iplocation = j.Deserialize<IPLocation>(_content); return Iplocation; }
/// <summary> /// 根据ipv4地址获取城市id /// </summary> /// <param name="_ip"></param> /// <returns></returns> public string getCityId(string _ip) { IPLocation iplocation = new IPLocation(); string locationString = getLocation(_ip); if (locationString == null) { return null; } iplocation = ParaseString(locationString, iplocation); string city = iplocation.content.address_detail.city; string province = iplocation.content.address_detail.province; string districts = iplocation.content.address_detail.district; string cityid = GetCityId.getCityId(province, city, districts); return cityid; }