Created
September 17, 2013 20:18
-
-
Save davidcroda/6599988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* GooglesController | |
* | |
* @author David Roda | |
* @package services | |
*/ | |
/** | |
* Unused class to control Google Plus API | |
* @package services | |
*/ | |
class GooglesController extends AppController { | |
var $name = 'Googles'; | |
function index() { | |
$this->Google->recursive = 0; | |
$this->set('googles', $this->paginate()); | |
} | |
function view($id = null) { | |
if (!$id) { | |
$this->Session->setFlash(__('Invalid google', true)); | |
$this->redirect(array('action' => 'index')); | |
} | |
$this->set('google', $this->Google->read(null, $id)); | |
} | |
function test($id) { | |
$this->autoRender = false; | |
App::import('Vendor', 'apiClient', array('file' => 'google-api-php-client/src/apiClient.php')); | |
App::import('Vendor', 'apiPlusService', array('file' => 'google-api-php-client/src/contrib/apiPlusService.php')); | |
$this->Google->id = $id; | |
$client = new apiClient(); | |
$google = $this->Google->read(); | |
$client->setAccessToken($google['Google']['access_token']); | |
$plus = new apiPlusService($client); | |
$activies = $plus->activities->listActivities($google['Google']['service_id'],'public'); | |
debug($activies); | |
$test = $plus->activities->listActivities($google['Google']['service_id'],'public',array('pageToken'=>$activies['nextPageToken'])); | |
debug($test); | |
foreach ($activies['items'] as $activity) { | |
$comments = $plus->comments->listComments($activity['id']); | |
debug($comments); | |
} | |
//$page = $plus->people->get('109272109884152049197'); | |
//debug($page); | |
} | |
function getPageIdFromUrl($url) { | |
// https://plus.google.com/b/104486355569593762406/ | |
$this->autoRender = false; | |
preg_match('/https:\/\/plus\.google\.com\/.+?b\/([0-9]+)/',$url,$matches); | |
if(isset($matches[1])) { | |
return $matches[1]; | |
} else { | |
return false; | |
} | |
} | |
function disconnect($id = null) { | |
if (!$id) { | |
$this->Session->setFlash(__('Invalid id for google', true)); | |
$this->redirect($this->referer()); | |
} | |
if ($this->Google->delete($id)) { | |
$this->Session->setFlash(__('Google Plus Successfully disconnected', true)); | |
$this->redirect($this->referer()); | |
} | |
$this->Session->setFlash(__('Error disconnecting Google Plus', true)); | |
$this->redirect($this->referer()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment