コード例 #1
0
 public function testRpcBatch()
 {
     $url = new Url();
     $url->longUrl = "http://google.com";
     $short0 = $this->service->url->insert($url);
     $url = new Url();
     $url->longUrl = "http://www.google.com";
     $short1 = $this->service->url->insert($url);
     $ret = apiBatch::execute($this->apiClient->urlshortener->url->get(array('shortUrl' => $short0['id']), 'url0'), $this->apiClient->urlshortener->url->get(array('shortUrl' => $short1['id']), 'url1'));
     $this->assertArrayHasKey('url0', $ret);
     $this->assertArrayHasKey('url1', $ret);
     $this->assertArrayHasKey('id', $ret['url0']);
     $this->assertArrayHasKey('longUrl', $ret['url0']);
 }
コード例 #2
0
ファイル: batch.php プロジェクト: robertflitsch/cs50-psets
<?php

session_start();
require_once "../src/apiClient.php";
$client = new apiClient();
$client->discover('plus');
$client->setScopes(array('https://www.googleapis.com/auth/plus.me'));
if (isset($_GET['logout'])) {
    unset($_SESSION['token']);
}
if (isset($_GET['code'])) {
    $client->authenticate();
    $_SESSION['token'] = $client->getAccessToken();
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}
if (isset($_SESSION['token'])) {
    $client->setAccessToken($_SESSION['token']);
    $ret = apiBatch::execute($client->plus->activities->list(array('userId' => 'me', 'collection' => 'public'), 'listActivities'), $client->plus->people->get(array('userId' => 'me'), 'getPerson'));
    print "<pre>" . print_r($ret, true) . "</pre>";
} else {
    $client->authenticate();
}
コード例 #3
0
<?php
session_start();

require_once "../src/apiClient.php";

$apiClient = new apiClient();
$apiClient->discover('buzz');
$apiClient->authenticate();

if (isset($_SESSION['oauth_access_token'])) {
  $apiClient->setAccessToken($_SESSION['oauth_access_token']);
} else {
  $token = $apiClient->authenticate();
  $_SESSION['oauth_access_token'] = $token;
}

$ret = apiBatch::execute(
  $apiClient->buzz->activities->list(array('userId' => '@me', 'scope' => '@consumption'), 'listActivitiesKey'),
  $apiClient->buzz->people->get(array('userId' => '@me'), 'getPeopleKey')
);

echo "<pre>" . print_r($ret, true) . "</pre>";