0

所以。我有以下来自第三方的 URL,可通过 API 调用访问。

https://scontent.xx.fbcdn.net/v/t1.0-9/15665479_1260320054027269_4201232212927955955_n.jpg?oh=ee01f2ec47b2e972bc12f99d988db241&oe=5946A159

我想在我的操作方法中使用 Google 缩短器缩短此 URL,我应该怎么做?

注意:安装了 goo.gl shortner nuget 包。

4

1 回答 1

3
class Program
{ 
    static void Main(string[] args)
    {

       UrlshortenerService service = new UrlshortenerService(new BaseClientService.Initializer()
        {
            ApiKey = "API KEY from Google developer console",
            ApplicationName = "Daimto URL shortener Sample",
        });

        var m = new Google.Apis.Urlshortener.v1.Data.Url();
        m.LongUrl = @"https://scontent.xx.fbcdn.net/v/t1.0-9/15665479_1260320054027269_4201232212927955955_n.jpg?oh=ee01f2ec47b2e972bc12f99d988db241&oe=5946A159";
        var shortenedUrl =  service.Url.Insert(m).Execute().Id;

        Console.WriteLine(shortenedUrl);
        Console.ReadKey();
    }

}
于 2017-02-27T09:39:53.210 回答