Question

I'd like to link my google plus account to my web site, using php, in order to display posts from my google plus account (without going through the autentification process). Is that doable, and if it is what google api should I use ?

Regards

Was it helpful?

Solution

You can only retrieve public posts for any account. The broad answer is that you can perform API calls to the activities.list API method as an unauthenticated app and can retrieve public posts for users with specific user IDs (1xxxxxxxxxxx rather than "me").

You can use the Google Client library for PHP to make the requests easier. Assuming you have a fully connected Google_client object and an instantiated Google_PlusService, you would be able to call:

$client = new Google_Client();
$client->setApplicationName('My Google+ PHP App');
// Visit https://code.google.com/apis/console?api=plus to generate your
// client id, client secret, and to register your redirect uri.
$client->setClientId('insert_your_oauth2_client_id');
$client->setClientSecret('insert_your_oauth2_client_secret');
$client->setRedirectUri('insert_your_oauth2_redirect_uri');
$client->setDeveloperKey('insert_your_simple_api_key');
$plus = new Google_PlusService($client);
$posts = $plus->activities->listActivities('106189723444098348646', 'public', array());

The example above would retrieve the first page of Larry Page's public posts.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top