1

首先抱歉我的英語不好。 任務是使用API​​在instagram中進行身份驗證。當我在用戶點擊「確定」後嘗試獲取令牌時,我從HttpWebResponse得到403錯誤,並且無法獲得我的令牌:(。我不知道該怎麼做,請幫助我。在我瀏覽器 - 這是確定從HttpWebResponse 403錯誤Instagram

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://instagram.com" + url); 
request.UserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"; 
request.Method = "POST"; 
request.CookieContainer = cookies; 
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; 
request.Headers.Add("Accept-Encoding: gzip, deflate"); 
request.Headers.Add("Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4"); 
request.Headers.Add("Cache-Control:max-age=0"); 
request.ContentType = "application/x-www-form-urlencoded"; 
request.Host = "instagram.com"; 
request.Headers.Add("Origin: https://instagram.com"); 
StreamWriter writer = new StreamWriter(request.GetRequestStream()); 
writer.Write("csrfmiddlewaretoken=" + par + "&username=LOGIN&password=PASSWORD"); 
writer.Close(); 
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); //403 ERORR 

回答

0

,只需發送一個用戶名/口令對到API你必須引導用戶登錄到Instagram的授權網址,並經過一個真實的用戶無法獲得訪問令牌!成功地Instagram會將您的應用程序代碼用於獲取訪問令牌。

更多信息:https://instagram.com/developer/authentication/