位用户:get

需要授权

根据 User-ID 检索用户。立即试用查看示例

请求

HTTP 请求

GET https://www.googleapis.com/blogger/v3/users/userId

参数

参数名称 说明
必需参数
userId string 当前用户的数字 ID 或 self

授权

此请求需要获得以下至少一个范围的授权(详细了解身份验证和授权)。

范围
https://www.googleapis.com/auth/blogger
https://www.googleapis.com/auth/blogger.readonly

请求正文

使用此方法时请勿提供请求正文。

响应

如果成功,此方法将在响应正文中返回 Users 资源

示例

注意:此方法的代码示例并未列出所有受支持的编程语言(请参阅客户端库页面,查看受支持的语言列表)。

Java

使用 Java 客户端库

// 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-UsersGet-Snippet/1.0")
.setHttpRequestInitializer(credential).build();
// The request action.
Get usersGetAction = blogger.users().get("self");
// Restrict the result content to just the data we need.
usersGetAction.setFields("displayName,url");
// This step sends the request to the server.
User user = usersGetAction.execute();
// Now we can navigate the response.
System.out.println("Display Name: " + user.getDisplayName());
System.out.println("Profile URL: " + user.getUrl());

试试看!

请使用下面的 API Explorer 针对实际数据调用此方法,然后查看响应。