* * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ // Include the Google API Client library, and the Buzz Service wrapper require_once "../../src/apiClient.php"; require_once "../../src/contrib/apiBuzzService.php"; // Include the utility function to display a buzz post- This is only intended to be a demo and a developer should create the UI that works for their app require_once 'includes/displayBuzzPost.php'; // Setup the API Client, and create the Buzz client using it $apiClient = new apiClient(); $buzz = new apiBuzzService($apiClient); // If a oauth token was stored in the session, use that- and otherwise go through the oauth dance if (isset($_SESSION['auth_token'])) { $apiClient->setAccessToken($_SESSION['auth_token']); } else { // In a real application this would be stored in a database, and not in the session! $_SESSION['auth_token'] = $apiClient->authenticate(); } // Include the common header UI require_once "includes/header.php"; // Get the consumption stream (the activities from the people you're following) for @me, which means 'the authenticated user', using $buzz->listActivities() $activities = $buzz->listActivities('@public', '@me', 50, 50, null, 50); //echo "<pre>".print_r($activities, true)."</pre>"; foreach ($activities['items'] as $buzzPost) { displayBuzzPost($buzzPost); }
<?php session_start(); require_once "../src/apiClient.php"; require_once "../src/contrib/apiBuzzService.php"; $apiClient = new apiClient(); $buzz = new apiBuzzService($apiClient); //$apiClient->discover('buzz'); if (isset($_SESSION['oauth_access_token'])) { $apiClient->setAccessToken($_SESSION['oauth_access_token']); } else { $token = $apiClient->authenticate(); $_SESSION['oauth_access_token'] = $token; } /* // some day this should just work, however right now JSON-RPC only does unauthenticated requests.. $ret = apiBatch::execute( $apiClient->buzz->activities->list(array('userId' => '@me', 'scope' => '@self'), 'listActivitiesKey'), $apiClient->buzz->people->get(array('userId' => '@me'), 'getPeopleKey') ); echo "<pre>" . print_r($ret, true) . "</pre>"; */ /* $group = $buzz->insertGroups('@me', array('data' => array('title' => 'Test Group'))); echo "<pre>Created initial group:\n" . print_r($group, true) . "</pre>"; $group = $buzz->updateGroups($group['id'], '@me', array('data' => array('title' => 'Updated Group'))); echo "<pre>Updated group:\n" . print_r($group, true) . "</pre>"; echo "getGroups({$group['id']}, '@me');<br>"; $group = $buzz->getGroups($group['id'], '@me');
/** * @depends testGetPublicStream */ public function testUnauthenticatedStream() { global $apiConfig; // test unauthenticated public stream fetching $apiConfig['authClass'] = 'apiAuthNone'; $apiClient = new apiClient(); $buzz = new apiBuzzService($apiClient); $apiClient->setAccessToken($apiConfig['oauth_test_token']); // fetch the unauthenticated, public activity streamn $activities = $buzz->listActivities('@public', $apiConfig['oauth_test_user']); // and evaluate it $this->evaluateActivitiesStream($activities); // restore the default Auth class & clean up $apiConfig['authClass'] = 'apiOAuth'; unset($buzz); unset($apiClient); unset($activities); }