Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting posts from google plus page

I would like to get content (posts) from a google+ page and post it to my website, as a feed. Is there any info how?

I read that current API does not allow that, but those topics were from the last year.

Thanks.

like image 996
Dino Velić Avatar asked Jan 31 '13 10:01

Dino Velić


3 Answers

You can perform activities.list, without having to authenticate, by passing your "simple" key from the API console for a project created that has the Google+ service turned on. Access to the API calls is restricted to the authorized origins you set up in your project.

After you create the project, in the section "Simple API Access" there is an API key. Build your client with this key, your client id, and client secret:

<?
    $client = new Google_Client();
    $client->setDeveloperKey("YOUR_API_KEY");
    $plus = new Google_PlusService($client);
    $activities = $plus->activities->listActivities("+GooglePlusDevelopers", "public");
?>
<html><body><pre><? echo print_r($activities);?></pre></body></html>

A final note, make sure you use the latest Google+ PHP client.

like image 163
class Avatar answered Oct 13 '22 11:10

class


After some time I found it.

http://code.google.com/p/google-plus-php-starter/

and this

https://developers.google.com/+/api/latest/activities/list

The only problem is that you need to log into your google app to do this. Any sugggestions would be apprecited.

like image 40
Dino Velić Avatar answered Oct 13 '22 11:10

Dino Velić


Updating the correct answer, the class name has changed to Google_Service_Plus

<?php
    set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ .'/vendor/google/apiclient/src');
    require_once __DIR__.'/vendor/autoload.php';

    $client = new Google_Client();
    $client->setDeveloperKey("YOUR_API_KEY");
    $plus = new Google_Service_Plus($client);
    $activities = $plus->activities->listActivities("+GooglePlusDevelopers", "public");
?>

$items = $activities->getItems();
foreach($items as $item) {

   $object = $item->getObject();
?>

<div class="gpost">
   <p><?php echo $object->getContent(); ?></p>
   <a href="<?php echo $item['url']; ?>">Read more</a>
</div>

<?php } ?>
like image 39
Joel Davey Avatar answered Oct 13 '22 10:10

Joel Davey