C# 如何使用Blogger API v3
以下是博主的API v3页面: 并下载了NuGet Blogger API包: 我的开发环境是Visual Studio 2010和C#语言 我如何使用Blogger的API 我只是不明白他们写了什么 如何初始化一个新的博客服务并获得所有帖子的列表C# 如何使用Blogger API v3,c#,api,blogger,C#,Api,Blogger,以下是博主的API v3页面: 并下载了NuGet Blogger API包: 我的开发环境是Visual Studio 2010和C#语言 我如何使用Blogger的API 我只是不明白他们写了什么 如何初始化一个新的博客服务并获得所有帖子的列表 在哪里使用我的应用程序进行身份验证(ClientID和ClientSecret)?您需要GDATA客户端,为此您需要下载Google API。 下载它。您需要安装该MSI,它将向您的系统添加dll和示例 C:\Program Files\Google
在哪里使用我的应用程序进行身份验证(ClientID和ClientSecret)?您需要GDATA客户端,为此您需要下载Google API。 下载它。您需要安装该MSI,它将向您的系统添加dll和示例 C:\Program Files\Google\Google数据API SDK
Google.GData.Blogger.dll
添加到项目中Service service = new Service("blogger", "blogger-example");
string username = "abc@gmail.com";
string password = "abc143";
service.Credentials = new GDataCredentials(username, password);
首先,您必须从下面的链接安装Blogger的API v3 您是为API V2安装的 这个链接中没有代码 目前我正在做这件事,它不会来了 这是一个现代的C#示例解决方案,使用控制台应用程序中的API密钥访问Blogger v3 API 创建新的.NET Framework控制台应用程序项目 安装以下NuGet软件包: 将主代码替换为以下代码:
static void Main(string[] args)
{
Console.WriteLine("Blogger API Sample");
Console.WriteLine("==================");
CancellationTokenSource cts = new CancellationTokenSource();
System.Console.CancelKeyPress += (s, e) =>
{
e.Cancel = true;
cts.Cancel();
};
try
{
MainAsync(args, cts.Token).Wait();
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("EXCEPTION: " + e.Message);
}
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
static async Task MainAsync(string[] args, CancellationToken ct)
{
if (args == null || args.Length != 1) args = new string[] { "http://blogger.googleblog.com/" };
// Create the service.
BloggerService service = new BloggerService(new BaseClientService.Initializer
{
ApplicationName = "Your Blogger App Name Here",
ApiKey = "[YOUR_API_KEY_HERE]",
});
// Run the blog request.
Console.WriteLine($"Executing blog {url} request...");
var blogResult = await service.Blogs.GetByUrl(url).ExecuteAsync(ct);
// Display the results.
if (blogResult.Posts != null)
{
//Run the posts request
Console.WriteLine($"Executing posts {blogResult.Posts.SelfLink} request...");
var postsResult = await service.Posts.List(blogResult.Id).ExecuteAsync(ct);
foreach (var post in postsResult.Items)
{
Console.WriteLine($"{post.Id} - {post.Title}");
}
}
}
@加林:我怀疑。那它用什么呢?我最近使用API 3开发了这个实用程序,而且我肯定使用了Google.GData.Blogger.dll。我在这里遗漏了什么吗?您的代码在过去10个月之前就已经使用了,但现在是changedOP要求使用API密钥。