使用者:get

需要授權

依使用者 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());