2012-08-14 5 views
1

내가 구글 페이지 모두 확인 을 시작 얻을 때 웹, 에서 페이지를 얻기 위해 웹 클라이언트를 사용 오전하지만 난 VK API를 웹 클라이언트의 반환 레르에서 페이지를 얻을 때 찾을 수없는,하지만 브라우저가 정상 내 코드 페이지를 엽니 다윈도우 폰 웹 클라이언트

private void log_Click(object sender, RoutedEventArgs e) 
{ 
    string auth; 
    string login = Uri.EscapeUriString(this.login.Text); 
    string password = Uri.EscapeUriString(this.pass.Password); 
    auth = "https://api.vk.com/oauth/token"; 
    auth += "?grant_type=password" + "&client_id=id&client_secret=code&username=" + login + "&password=" + password + "&scope=notify,friends,messages"; 

    //auth = "https://google.com/"; 

    WebClient client = new WebClient(); 
    client.DownloadStringCompleted +=new DownloadStringCompletedEventHandler(client_DownloadStringCompleted); 
    Uri.EscapeUriString(auth); 
    client.DownloadStringAsync(new Uri(auth)); 
} 
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) 
{ 
    if (e.Error == null) 
     MessageBox.Show("Using WebClient: " + e.Result); 

    else 
     MessageBox.Show(e.Error.Message); 
} 
+0

때때로 문제를해야합니다 유효하지 않은 인증서가있는 서버에 https 연결이 설정되었습니다. –

답변

2

이것은 비 200 응답 상태에서만위한 https 호출을 발생합니다. 올바른 자격증 명으로 Not found을받은 경우 요청 매개 변수를 확인하십시오.

200이 해결 방법을 시도해보십시오

client.AllowReadStreamBuffering = true; 
또한

, 내가 볼을 내 생각이 라인 Uri.EscapeUriString(auth);는 WP7 스택 오버 플로우에 게시이 항상 끝나게 같은 auth = Uri.EscapeUriString(auth);

+0

코드를 변경하고 WebClient 클라이언트 = new WebClient(); 하지만이 작동하지 않습니다 – user1597524

+0

브라우저에서이 요청을 호출하면 인증은 성공적입니까? – Ku6opr

+0

예. 이 브라우저에서 작동합니다. – user1597524