Hide

Comments: get

Get a comment. Try it now or see an example.

Request

HTTP request

GET https://www.googleapis.com/plus/v1/comments/commentId

Parameters

Parameter name Value Description
Path parameters
commentId string The ID of the comment to get.

Request body

Do not supply a request body with this method.

Response

If successful, this method returns a comment resource in the response body.

Examples

Note: The code examples available for this method do not represent all supported programming languages (see the client libraries page for a list of supported languages).

Java

Uses the Java client library.

// This sample assumes a client object has been created.
// To learn more about creating a client, check out the starter:
//  https://developers.google.com/+/quickstart/java

Comment comment = plus.comments().get(commentId).execute();

System.out.println("Got comment with ID " + comment.getId() +
        " and contents " + comment.getObject().getContent());

PHP

Uses the PHP client library.

# This sample assumes a client object has been created.
# To learn more about creating a client, check out the starter:
#  https://developers.google.com/+/quickstart/php

$comment = $plus->comments->get('z12gtjhq3qn2xxl2o224exwiqruvtda0i.1317750454233000');
print "{$comment['id']}, {$comment['object']['content']}\n";

Python

Uses the Python client library.

# This sample assumes a client object has been created.
# To learn more about creating a client, check out the starter:
#  https://developers.google.com/+/quickstart/python

comments_resource = service.comments()
comment = comments_resource.get(commentId=comment_id).execute()

print comment['id'], comment['object']['content']

Ruby

Uses the Ruby client library.

# This sample assumes a client object has been created.
# To learn more about creating a client, check out the starter:
#  https://developers.google.com/+/quickstart/ruby

status, headers, body = client.execute(
  plus.comments.get,
  {'commentId' => id})

return status if status != 200

response = JSON.parse(body[0])

# Print out the comment
puts "Comment: #{response['id']} with content #{response['object']['content']}"

Go

Uses the Go client library.

comment, err := plusService.Comments.Get(commentId).Do()

JavaScript

Uses the JavaScript client library.

// This sample assumes a client object has been created.
// To learn more about creating a client, check out the starter:
//  https://developers.google.com/+/quickstart/javascript
var request =
   gapi.client.plus.comments.get({'commentId' : commentId});
request.execute(function(resp) { console.log('Got comment with ID: ' + resp.id + ' and content: ' + resp.object.content); }

Try it!

Use the APIs Explorer below to call this method on live data and see the response. Alternatively, try the standalone Explorer.

Send feedback about...

Google+ Platform for Web