وبلاگ ها: getByUrl

یک وبلاگ را با URL بازیابی می کند. اکنون آن را امتحان کنید یا نمونه ای را ببینید .

اگر وبلاگ خصوصی است مجوز لازم است. اگر وبلاگ عمومی است، این روش را می توان بدون مجوز فراخوانی کرد.

درخواست

درخواست HTTP

GET https://www.googleapis.com/blogger/v3/blogs/byurl

مولفه های

نام پارامتر ارزش شرح
پارامترهای مورد نیاز
url string آدرس وبلاگ برای بازیابی.

درخواست بدن

با این روش بدنه درخواستی ارائه نکنید.

واکنش

در صورت موفقیت آمیز بودن، این روش یک منبع Blogs را در بدنه پاسخ برمی گرداند.

مثال ها

توجه: نمونه‌های کد موجود برای این روش همه زبان‌های برنامه‌نویسی پشتیبانی‌شده را نشان نمی‌دهند (برای فهرست زبان‌های پشتیبانی‌شده به صفحه کتابخانه‌های سرویس گیرنده مراجعه کنید).

جاوا

از کتابخانه کلاینت جاوا استفاده می کند

String CODE_BLOG_URL = "http://code.blogger.com/";
// Configure the Java API Client for Installed Native App
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
// Configure the Installed App OAuth2 flow.
Credential credential = OAuth2Native.authorize(HTTP_TRANSPORT,
JSON_FACTORY, new LocalServerReceiver(),
Arrays.asList(BloggerScopes.BLOGGER));
// Construct the Blogger API access facade object.
Blogger blogger = Blogger.builder(HTTP_TRANSPORT, JSON_FACTORY)
.setApplicationName("Blogger-BlogGetByUrl-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action object.
GetByUrl blogGetByUrlAction = blogger.blogs().getByUrl();
// Configure which blog URL to look up.
blogGetByUrlAction.setUrl(CODE_BLOG_URL);
// Restrict the result content to just the data we need.
blogGetByUrlAction.setFields("description,name,posts/totalItems,updated");
// This step sends the request to the server.
Blog blog = blogGetByUrlAction.execute();
// Now we can navigate the response.
System.out.println("Name: " + blog.getName());
System.out.println("Description: " + blog.getDescription());
System.out.println("Post Count: " + blog.getPosts().getTotalItems());
System.out.println("Last Updated: " + blog.getUpdated());

آن را امتحان کنید!

از APIs Explorer زیر برای فراخوانی این روش در داده‌های زنده و دیدن پاسخ استفاده کنید.