Postagens: getByPath

Recupera uma postagem por caminho. Faça um teste agora ou veja um exemplo.

A autorização será necessária se a postagem estiver em um blog particular.

O caminho da postagem faz parte do URL dela depois do host. Por exemplo, uma postagem de blog com o URL http://code.blogger.com/2011/09/blogger-json-api-now-available.html tem um caminho /2011/09/blogger-json-api-now-available.html.

Solicitação

Solicitação HTTP

GET https://www.googleapis.com/blogger/v3/blogs/blogId/posts/bypath

Parâmetros

Nome do parâmetro Valor Descrição
Parâmetros obrigatórios
blogId string O ID do blog a partir do qual a postagem será buscada.
path string Caminho da postagem a ser recuperada.
Parâmetros opcionais
maxComments unsigned integer Número máximo de comentários a serem recuperados para uma postagem. Se esse parâmetro não for especificado, nenhum comentário será retornado como parte do recurso post.
view string

Os valores aceitáveis são:
  • "ADMIN": detalhe do nível de administrador
  • "AUTHOR": detalhe do nível do autor
  • "READER": detalhe do nível de administrador

Corpo da solicitação

Não forneça um corpo de solicitação com este método.

Resposta

Se for bem-sucedido, este método retornará um recurso Posts no corpo da resposta.

Exemplos

Observação: os exemplos de código disponíveis para esse método não representam todas as linguagens de programação compatíveis. Consulte a página de bibliotecas cliente para ver uma lista de linguagens compatíveis.

Java

Usa a biblioteca cliente de Java

// The BlogId for the http://buzz.blogger.com/ blog.
String BUZZ_BLOG_ID = "2399953";
// 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 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-PostsGetByPath-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
GetByPath postsGetByPathAction = blogger.posts().getByPath(BUZZ_BLOG_ID);
postsGetByPathAction.setPath(BUZZ_POST_PATH);
// Restrict the result content to just the data we need.
postsGetByPathAction.setFields("content,published,title");
// This step sends the request to the server.
Post post = postsGetByPathAction.execute();
// Now we can navigate the response.
System.out.println("Title: " + post.getTitle());
System.out.println("Published: " + post.getPublished());
System.out.println("Content: " + post.getContent());

Confira!

Use o APIs Explorer abaixo para chamar esse método em dados ativos e ver a resposta.