1#
得到code参数让.net通过web应用验证请求新浪微博获得accesstoken

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.weibo.com/oauth2/access_token");

            request.Method = "POST";

            request.ContentType = "application/x-www-form-urlencoded;";

            request.Headers.Add(string.Format("Authorization: key={0}", "123456"));

            string postData = "client_id=123";
            postData += ("&client_secret=123");
            postData += ("&grant_type=authorization_code");
            postData += ("&redirect_uri=http://www.cfxixi.com");
            postData += ("&code=123");

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);

            request.ContentLength = byteArray.Length;

            Stream dataStream = request.GetRequestStream();

            dataStream.Write(byteArray, 0, byteArray.Length);

            dataStream.Close();



            //發出Request

            WebResponse response = request.GetResponse();

            Stream responseStream = response.GetResponseStream();

            StreamReader reader = new StreamReader(responseStream);

            string input= reader.ReadToEnd();

            reader.Close();

            responseStream.Close();

            response.Close();

            return String.Format("The (jsonp) input string was: {0}", input);