Google+ Platform

Activities: get

Get an activity. Try it now or see an example.

Request

HTTP request

GET https://www.googleapis.com/plus/v1/activities/activityId

Parameters

Parameter name Value Description
Required parameters
activityId string The ID of the activity to get.

Request body

Do not supply a request body with this method.

Response

If successful, this method returns an activity 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

Activity activity = plus.activities().get(activityId).execute();
System.out.println("Used get to fetch activity with ID " + activity.getId());
System.out.println(" Activity content:\t" + activity.getObject().getContent());
System.out.println(" +1's: \t" + activity.getObject().getPlusoners().getTotalItems());
System.out.println(" Reply comments: \t" + activity.getObject().getReplies().getTotalItems());

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

$activity = $plus->activities->get($activity_id);
print "Title: {$activity['title']}\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

activities_resource = service.activities()
activity = activities_resource.get( \
    activityId=activity_id).execute()
print activity['id'], activity['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.activities.get,
  {'activityId' => id})

return status if status != 200

activity = JSON.parse(body[0])

puts "Activity: #{activity['id']} " + 
  "with title #{activity['title']} " + 
  "with content #{activity['object']['content']}"

.NET

Uses the .NET 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/csharp

Activity activity = ps.Activities.Get(activityId).Fetch();

if (activity != null)
{
  Console.WriteLine(a.Title);
  Console.WriteLine(a.Url);
  Console.WriteLine(a.Published);                
}

Go

Uses the Go client library

activity, err := plusService.Activities.Get(activityId).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.activities.get({ 'activityId' : activityId });

request.execute(function(resp) {
  console.log('Used get to fetch activity with ID: ' + resp.id);
  
console.log('Activity content: ' + resp.object.content);
  console.log('+1s: ' + resp.object.plusoners.totalItems);
  console.log('Number of comments: ' + resp.object.replies.totalItems);
});

Try it!

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

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.