0
Google 단축 URL을 사용하여 프로젝트의 URL을 줄이고 HTTPRequestException 처리되지 않은 오류가 계속 발생하려고합니다. 내가 처음 실행했을 때 거기에 없었던 .cs 파일을 찾으려고 했으므로 나는 그 파일을 추측하고있다. 난 그냥 Visual Studio에서 이것을 얻기 위해 너겟 설치 프로그램을 사용했습니다. 어떤 아이디어?Google shortenurl API를 사용하여 짧은 URL 만들기
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Google.Apis.Urlshortener.v1;
using Google.Apis.Oauth2;
using Google.Apis.Services;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
namespace ShortenURL
{
class Program
{
static void Main(string[] args)
{
var originalURL = "https://www.google.com/maps/place/Desert+Christian+Schools/@32.2367293,-110.8339121,16.75z/data=!4m7!1m4!3m3!1s0x86d66f1806d996d7:0xe8ac20e8cebb38b9!2s7525+E+Speedway+Blvd,+Tucson,+AZ+85710!3b1!3m1!1s0x86d66f1806d996d7:0x7b90764e4e6a25d8";
string shortUrl = Shorten(originalURL);
Console.WriteLine(shortUrl);
Console.WriteLine("FINISHED");
Console.ReadLine();
}
private const string key = "AIzaSyB3pfstkvAZzEVOy4dNHaKTuNmtDaG3XsI";
public static string Shorten(string url)
{
UrlshortenerService service = new UrlshortenerService(new BaseClientService.Initializer()
{
ApiKey = key,
ApplicationName = "ShortenUrlAHLI"
});
var m = new Google.Apis.Urlshortener.v1.Data.Url();
m.LongUrl = url;
return service.Url.Insert(m).Execute().Id;
}
}
}
좀 더 구체적으로해야한다. 적어도 완전한 예외 정보. –
System.Net.Http.HttpRequestException : 요청을 보내는 동안 오류가 발생했습니다. ---> System.Net.WebException : 원격 서버가 오류를 반환했습니다 : (407) 프록시 인증 필요. System.Net.Http.HttpClientHandler.GetRequestStreamCallback에서 System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult를 asyncResult, TransportContext 및 컨텍스트) (IAsyncResult를 아칸소) – JW12689
--- 내부 예외 스택 추적 --- 끝에서 Google.Apis 에서 . C : \ Apiary \ v1.22 \ google-api-dotnet-client \ Src \ Support \ GoogleApis \ Apis \ Requests \ ClientServiceRequest.cs의 Requests.ClientServiceRequest'1.Execute() : 줄 101 ShortenURL.Program.Shorten (문자열 URL) C : \ Users \ justinwendo \ Desktop \ test_VB_projects \ ShortenURL \ ShortenURL \ Program.cs : line 37 – JW12689