Beispiel #1
0
        static void Test()
        {
            string did, privateKey;
            var    result = CertificateUtil.GetPfxPrivateKeyAndDidValue(@"C:\Users\Administrator\Desktop\pfx\weibo\api.jk.cn(2).pfx",
                                                                        out privateKey, out did);

            if (result)
            {
                ParaCollection pc = new ParaCollection();
                pc.Add("_did", did);
                pc.Add("_dtk", "Ly/4WjYKFOqZuYtY739SvsOkR73FUuy6heTKB3lm/T6xYBYhnXcRBvkvZ/WEQFEX2yN3F4+x3uvsDuSs/nnij+SSeH2JLTMYhMnLaa8Crc4kGWvZHbuRSK/whrQ2ceCRdKSGVm3PfamQQ9MPBh/r4AvM9wt5Paduw+FxxT+6mH60vlSU7utJV4xDuuBByvAi/cYU6hAqwxYTDMv3tOS3V6qm0LhlRxJHExMGrPgzCIqctsspemin04iurHDOkG30x+VN0CkuWdcpk7PsBQVIQA==", true);
                pc.Add("_mt", "user.weiboLogin");
                pc.Add("_chl", "MZSD");
                pc.Add("accessToken", "2.00vpN7TBvqH7EDbd3ddc819a7Xdi2C");
                pc.Add("_sm", "rsa");
                pc.Add("_aid", "1");
                pc.Add("_vc", "30803");
                pc.Add("_ft", "json");

                //pc.Add("_did", did);
                //pc.Add("_mt", "user.getWebUserToken");
                //pc.Add("_uid", "12651160806");
                //pc.Add("_chl", "MZSD");
                //pc.Add("_sm", "rsa");
                //pc.Add("_tk", "KUUKALUWp9fVZCwkLXeJ4SIU1coPRWzcMjqoOj5+/I/SVJn8iplPyatsGiqmfw2kY0J5E/HFPKy6KFQ6zZ3BX8PogJsuLWZHH4J1g7gK4sI6EY6Dur2+fZKAfJqwsmuaZGrfO7tuzmE+JrWo27dbaLUnIQgG77ALu3UvgSSt2mqfHfQCFXnNaKglAuiBUETWptWunj4aasJ4G9ctwC+74Bd4n1d5jxHxjtxXdRUAZDFoawxDfeM8oZZPj4aH9OMwa8Hn2nX2g2O8DvGuDytat11mF6zqzJL52tggonHHRrXX6YxgO9188gNZQUwLXbkoDjKSJ7LlO9XrQ6iPlwiKH90HKvgKzQWhReweynjc73i4rnqVx7gUGV9xfpyXxYi6");
                //pc.Add("_aid", "1");
                //pc.Add("_vc", "30803");
                //pc.Add("_ft", "json");

                var sig = PapdHelper.CalcSig(pc.ToString(), null, privateKey);

                Console.WriteLine(sig);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 根据经纬度,获取附近的地址
        /// </summary>
        /// <param name="lng">经度值</param>
        /// <param name="lat">纬度值</param>
        /// <returns></returns>
        private List <LocationInfo> GetAddressInfoByLngLat(double lng, double lat)
        {
            ParaCollection pc = new ParaCollection();

            pc.Add("ak", "lf1Gq5WI7vUjqhR6W6IBqAXNVjI0V4F7");
            pc.Add("location", lat + "," + lng);
            pc.Add("output", "json");
            pc.Add("pois", "1");
            pc.Add("coordtype", "bd09ll");
            pc.Add("callback", "jsonP.callback_4");

            string    url    = "http://api.map.baidu.com/geocoder/v2/?" + pc.ToString();
            WebClient client = new WebClient();

            byte[] data = client.DownloadData(url);
            string json = System.Text.Encoding.UTF8.GetString(data);

            int    startIndex = json.IndexOf("(") + 1;
            int    endIndex   = json.LastIndexOf(")");
            string json2      = json.Substring(startIndex, endIndex - startIndex);

            JObject obj    = JsonConvert.DeserializeObject(json2) as JObject;
            JObject result = obj["result"] as JObject;

            List <LocationInfo> list = new List <LocationInfo>();

            list.Add(new LocationInfo()
            {
                IsDefault = true,
                Longitude = Convert.ToDouble(result["location"]["lng"].ToString()),
                Latitude  = Convert.ToDouble(result["location"]["lat"].ToString()),
                Name      = result["formatted_address"].ToString()
            });

            string province = result["addressComponent"]["province"].ToString();
            string city     = result["addressComponent"]["city"].ToString();
            string district = result["addressComponent"]["district"].ToString();

            JArray poisArray = result["pois"] as JArray;

            for (int i = 0; i < poisArray.Count; i++)
            {
                JObject pois = poisArray[i] as JObject;
                list.Add(new LocationInfo()
                {
                    Longitude = Convert.ToDouble(pois["point"]["x"].ToString()),
                    Latitude  = Convert.ToDouble(pois["point"]["y"].ToString()),
                    Name      = pois["addr"].ToString() + pois["name"].ToString(),
                });
            }

            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// 根据地名和所在城市,获取相关地址
        /// </summary>
        /// <param name="addressName">地名</param>
        /// <param name="city">所在城市</param>
        private List <LocationInfo> GetAddressInfoByName(string addressName, string city)
        {
            ParaCollection pc = new ParaCollection();

            pc.Add("ak", "lf1Gq5WI7vUjqhR6W6IBqAXNVjI0V4F7");
            pc.Add("q", addressName);
            pc.Add("output", "json");
            pc.Add("scope", "2");
            pc.Add("city_limit", "true");
            pc.Add("region", city);
            pc.Add("callback", "jsonP.callback_13");

            string    url    = "http://api.map.baidu.com/place/v2/suggestion?" + pc.ToString();
            WebClient client = new WebClient();

            byte[] data       = client.DownloadData(url);
            string json       = System.Text.Encoding.UTF8.GetString(data);
            int    startIndex = json.IndexOf("(") + 1;
            int    endIndex   = json.LastIndexOf(")");
            string json2      = json.Substring(startIndex, endIndex - startIndex);

            JObject obj    = JsonConvert.DeserializeObject(json2) as JObject;
            JArray  result = obj["result"] as JArray;

            List <LocationInfo> list = new List <LocationInfo>();

            for (int i = 0; i < result.Count; i++)
            {
                JObject addr = result[i] as JObject;
                list.Add(new LocationInfo()
                {
                    Longitude = Convert.ToDouble(addr["location"]["lng"].ToString()),
                    Latitude  = Convert.ToDouble(addr["location"]["lat"].ToString()),
                    Name      = "" + addr["city"] + addr["district"] + addr["name"],
                });
            }
            if (this.lstBoxAddress.Items.Count > 0)
            {
                (this.lstBoxAddress.Items[0] as LocationInfo).IsDefault = true;
            }

            return(list);
        }