ฉันยังใหม่ใน c # และฉันกำลังพยายามสร้างแอปพลิเคชันสำหรับเพจนี้ซึ่งจะแจ้งให้ฉันทราบเมื่อฉันได้รับการแจ้งเตือน (ตอบแสดงความคิดเห็น ฯลฯ ... ) แต่ตอนนี้ฉันแค่พยายามโทรไปที่ api ง่ายๆซึ่งจะได้รับข้อมูลของผู้ใช้
ฉันใช้ Visual studio express 2012 เพื่อสร้างแอปพลิเคชัน C # โดยที่ (ตอนนี้) คุณป้อนรหัสผู้ใช้ของคุณดังนั้นแอปพลิเคชันจะส่งคำขอด้วยรหัสผู้ใช้และแสดงสถิติของรหัสผู้ใช้นี้
นี่คือรหัสที่ฉันพยายามส่งคำขอ:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//Request library
using System.Net;
using System.IO;
namespace TestApplication
{
    class Connect
    {
        public string id;
        public string type;
        protected string api = "https://api.stackexchange.com/2.2/";
        protected string options = "?order=desc&sort=name&site=stackoverflow";
        public string request()
        {
            string totalUrl = this.join(id);
            return this.HttpGet(totalUrl);
        }
        protected string join(string s)
        {
            return api + type + "/" + s + options;
        }
        protected string get(string url)
        {
            try
            {
                string rt;
                WebRequest request = WebRequest.Create(url);
                WebResponse response = request.GetResponse();
                Stream dataStream = response.GetResponseStream();
                StreamReader reader = new StreamReader(dataStream);
                rt = reader.ReadToEnd();
                Console.WriteLine(rt);
                reader.Close();
                response.Close();
                return rt;
            }
            catch(Exception ex)
            {
                return "Error: " + ex.Message;
            }
        }
        public string HttpGet(string URI)
        {
            WebClient client = new WebClient();
            // Add a user agent header in case the 
            // requested URI contains a query.
            client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
            Stream data = client.OpenRead(URI);
            StreamReader reader = new StreamReader(data);
            string s = reader.ReadToEnd();
            data.Close();
            reader.Close();
            return s;
        }
    }
}คลาสเป็นอ็อบเจ็กต์และถูกเข้าถึงจากฟอร์มโดยเพียงแค่แยกวิเคราะห์ id ผู้ใช้และทำการร้องขอ
ฉันได้ลองดูหลายตัวอย่างใน Google แล้ว แต่ไม่ทราบสาเหตุว่าทำไมฉันถึงได้รับข้อความ " " นี้ทุกวิธี
ฉันเป็นคนใหม่ในอัลกอริทึมประเภทนี้หากใครสามารถแบ่งปันหนังสือหรือบทช่วยสอนที่แสดงวิธีการทำสิ่งนี้ (อธิบายแต่ละขั้นตอน) ฉันจะขอบคุณ
htmlสตริง+1เพื่อทำความสะอาดโค้ดโดยวิธี ..