如果文章位於私人網誌,則必須授權。
文章路徑是文章網址中主機後面的部分。舉例來說,網址為 http://code.blogger.com/2011/09/blogger-json-api-now-available.html
的網誌文章路徑為 /2011/09/blogger-json-api-now-available.html
。
要求
HTTP 要求
GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts/bypath
參數
參數名稱 | 值 | 說明 |
---|---|---|
必要參數 | ||
blogId |
string |
要從中擷取文章的網誌 ID。 |
path |
string |
要擷取的貼文路徑。 |
選用參數 | ||
maxComments |
unsigned integer |
要擷取文章留言的數量上限。如果未指定這項參數,系統就不會傳回任何留言,也不會將留言納入貼文資源。 |
view |
string |
可接受的值如下:
|
要求主體
請勿透過此方法提供要求主體。
回應
如果成功,這個方法會在回應內文中傳回 Posts 資源。
範例
注意:這個方法適用的程式設計語言眾多,我們只在此提供部分程式碼範例。如需查看所有支援語言,請參閱用戶端程式庫頁面。
Java
使用 Java 用戶端程式庫
// The BlogId for the http://buzz.blogger.com/ blog.
String BUZZ_BLOG_ID = "2399
953"; // The URL path component for a
buzz post.String BUZZ_POST_PATH = "/2012/01/engage-with-your-readers
-through.html"; // Configure the Java API Client for
Installed Native AppHttpTransport HTTP_TRANSPORT = new
NetHttpTransport();JsonFactory JSON_FACTORY = n
ew JacksonFactory(); // Configure the Instal
led App OAuth2 flow.Credential credential = OAuth2Native.autho
rize(HTTP_TRANSPORT, JSON_FACTORY, new Lo
calServerReceiver(), Arrays.asList(Blog
gerScopes.BLOGGER)); // Construct the Blogger API a
ccess facade object.Blogger blogger = Blogger.builder(HTTP_TRAN
SPORT, JSON_FACTORY) .setApplicationName("Blogger-Pos
tsGetByPath-Snippet/1.0") .setHttpRequestIn
itializer(credential).b
uild(); // The request action.GetByPath postsGetByPathAction = blogger.po
sts().getByPath(BUZZ_BLOG_ID);postsGetByPathA
ction.setPath(BUZZ_POST_PATH); // Restrict the result con
tent to just the data we need.postsGetByPathAction.setFiel
ds("content,published,title"); // Th
is step sends the request to the server.Pos
t post = postsGetByPathAction.execute
(); // Now we can navigate the response.System.o
ut.println("Title: " + post.getTitle());System
.out.println("Published: " + post.getPublished());System.out.println("Content: " + post.getContent());
試試看!
您可以使用下方的 API Explorer,針對即時資料呼叫這個方法,然後查看回應。