这里是Blogger的API v3页面。https:/developers.google.comloggerdocs3.0using
并下载了NuGet Blogger API包。https:/www.nuget.orgpackagesGoogle.Apis.blogger.v2
我的开发环境是Visual Studio 2010,使用C#语言。
我如何使用Blogger的API?
我只是不明白他们写的是什么 https:/developers.google.comresourcesapi-librariesdocumentationbloggerv3csharplatestnamespaces.html。 ...
如何初始化一个新的Blogger服务并获得所有帖子的列表?
在哪里用我的应用程序进行认证(ClientID和ClientSecret)?
你需要GDATA客户端,为此你需要下载Google API。此处. 你需要安装那个MSI,它将会在你的系统中添加dll,样本。
C:\\程序文件\Google\Google Data API SDK。
Google.GData.Blogger.dll
对您的项目 以下代码可用于创建服务并从Blogger中获取数据。
Service service = new Service("blogger", "blogger-example");
string username = "[email protected]";
string password = "abc143";
service.Credentials = new GDataCredentials(username, password);
这是一个现代的C#示例解决方案,在一个控制台应用程序中使用API KEY访问Blogger v3 API。
创建一个新的.NET框架控制台应用程序项目。
安装以下NuGet包。https:/www.nuget.orgpackagesGoogle.Apis.Blogger.v3
用以下代码替换你的Main代码。
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}");
}
}
}
首先,你必须从下面的链接中安装Blogger的API v3,你安装的是API V2。
https:/www.nuget.orgpackagesGoogle.Apis.Blogger.v3
中没有任何代码 https:/developers.google.comresourcesapi-librariesdocumentationbloggerv3csharplatestnamespaces.html。 这个环节
目前,我正在研究这个问题,它不会来。