├── README.md
├── files
└── example.txt
├── google-api-php-client
├── LICENSE
├── NOTICE
├── README
├── examples
│ ├── adexchangebuyer
│ │ ├── BaseExample.php
│ │ ├── examples
│ │ │ ├── GetAllAccounts.php
│ │ │ ├── GetCreative.php
│ │ │ ├── GetDirectDeals.php
│ │ │ ├── SubmitCreative.php
│ │ │ └── UpdateAccount.php
│ │ ├── htmlHelper.php
│ │ ├── index.php
│ │ └── style.css
│ ├── adsense
│ │ ├── AdSenseAuth.php
│ │ ├── BaseExample.php
│ │ ├── examples
│ │ │ ├── GenerateColumnChart.php
│ │ │ ├── GenerateGeoChart.php
│ │ │ ├── GenerateLineChart.php
│ │ │ ├── GeneratePieChart.php
│ │ │ ├── GenerateReport.php
│ │ │ ├── GenerateReportWithPaging.php
│ │ │ ├── GenerateTableChart.php
│ │ │ ├── GetAccountTree.php
│ │ │ ├── GetAllAccounts.php
│ │ │ ├── GetAllAdClients.php
│ │ │ ├── GetAllAdClientsForAccount.php
│ │ │ ├── GetAllAdUnits.php
│ │ │ ├── GetAllAdUnitsForCustomChannel.php
│ │ │ ├── GetAllCustomChannels.php
│ │ │ ├── GetAllCustomChannelsForAdUnit.php
│ │ │ └── GetAllUrlChannels.php
│ │ ├── htmlHelper.php
│ │ ├── index.php
│ │ └── style.css
│ ├── adsensehost
│ │ ├── AdSenseHostAuth.php
│ │ ├── BaseExample.php
│ │ ├── examples
│ │ │ ├── AddAdUnitToPublisher.php
│ │ │ ├── AddCustomChannelToHost.php
│ │ │ ├── AddUrlChannelToHost.php
│ │ │ ├── DeleteAdUnitOnPublisher.php
│ │ │ ├── DeleteCustomChannelOnHost.php
│ │ │ ├── DeleteUrlChannelOnHost.php
│ │ │ ├── GenerateReportForHost.php
│ │ │ ├── GenerateReportForPublisher.php
│ │ │ ├── GetAccountDataForExistingPublisher.php
│ │ │ ├── GetAllAdClientsForHost.php
│ │ │ ├── GetAllAdClientsForPublisher.php
│ │ │ ├── GetAllAdUnitsForPublisher.php
│ │ │ ├── GetAllCustomChannelsForHost.php
│ │ │ ├── GetAllUrlChannelsForHost.php
│ │ │ ├── StartAssociationSession.php
│ │ │ ├── UpdateAdUnitOnPublisher.php
│ │ │ ├── UpdateCustomChannelOnHost.php
│ │ │ └── VerifyAssociationSession.php
│ │ ├── htmlHelper.php
│ │ ├── index.php
│ │ └── style.css
│ ├── affiliateNetwork
│ │ └── index.php
│ ├── analytics
│ │ ├── demo
│ │ │ ├── authHelper.php
│ │ │ ├── coreReportingApiReference.php
│ │ │ ├── helloAnalyticsApi.php
│ │ │ ├── index.php
│ │ │ ├── managementApiReference.php
│ │ │ └── storage.php
│ │ └── simple.php
│ ├── apps
│ │ └── index.php
│ ├── batch.php
│ ├── books
│ │ ├── books_browser.css
│ │ ├── index.php
│ │ ├── interface.html
│ │ └── simple.php
│ ├── calendar
│ │ └── simple.php
│ ├── contacts
│ │ └── simple.php
│ ├── customSearch
│ │ └── index.php
│ ├── latitude
│ │ ├── index.php
│ │ └── style.css
│ ├── moments
│ │ └── simple.php
│ ├── pagespeed
│ │ ├── index.php
│ │ └── style.css
│ ├── plus
│ │ ├── README
│ │ ├── index.php
│ │ ├── simple.php
│ │ └── style.css
│ ├── prediction
│ │ ├── README
│ │ ├── index.php
│ │ ├── serviceAccount.php
│ │ └── style.css
│ ├── shopping
│ │ └── simple.php
│ ├── siteVerification
│ │ └── simple.php
│ ├── tasks
│ │ ├── css
│ │ │ └── style.css
│ │ └── index.php
│ ├── translate
│ │ └── simple.php
│ ├── urlshortener
│ │ ├── index.php
│ │ └── style.css
│ ├── userinfo
│ │ └── index.php
│ └── webfonts
│ │ └── simple.php
├── makeRelease.sh
├── src
│ ├── Google_Client.php
│ ├── auth
│ │ ├── Google_AssertionCredentials.php
│ │ ├── Google_Auth.php
│ │ ├── Google_AuthNone.php
│ │ ├── Google_LoginTicket.php
│ │ ├── Google_OAuth2.php
│ │ ├── Google_P12Signer.php
│ │ ├── Google_PemVerifier.php
│ │ ├── Google_Signer.php
│ │ └── Google_Verifier.php
│ ├── cache
│ │ ├── Google_ApcCache.php
│ │ ├── Google_Cache.php
│ │ ├── Google_FileCache.php
│ │ └── Google_MemcacheCache.php
│ ├── config.php
│ ├── contrib
│ │ ├── Google_AdExchangeSellerService.php
│ │ ├── Google_AdexchangebuyerService.php
│ │ ├── Google_AdsenseService.php
│ │ ├── Google_AdsensehostService.php
│ │ ├── Google_AnalyticsService.php
│ │ ├── Google_BigqueryService.php
│ │ ├── Google_BloggerService.php
│ │ ├── Google_BooksService.php
│ │ ├── Google_CalendarService.php
│ │ ├── Google_ComputeService.php
│ │ ├── Google_CustomsearchService.php
│ │ ├── Google_DriveService.php
│ │ ├── Google_FreebaseService.php
│ │ ├── Google_FusiontablesService.php
│ │ ├── Google_GanService.php
│ │ ├── Google_LatitudeService.php
│ │ ├── Google_LicensingService.php
│ │ ├── Google_ModeratorService.php
│ │ ├── Google_Oauth2Service.php
│ │ ├── Google_OrkutService.php
│ │ ├── Google_PagespeedonlineService.php
│ │ ├── Google_PlusMomentsService.php
│ │ ├── Google_PlusService.php
│ │ ├── Google_PredictionService.php
│ │ ├── Google_ShoppingService.php
│ │ ├── Google_SiteVerificationService.php
│ │ ├── Google_StorageService.php
│ │ ├── Google_TaskqueueService.php
│ │ ├── Google_TasksService.php
│ │ ├── Google_TranslateService.php
│ │ ├── Google_UrlshortenerService.php
│ │ ├── Google_WebfontsService.php
│ │ └── Google_YoutubeService.php
│ ├── external
│ │ └── URITemplateParser.php
│ ├── io
│ │ ├── Google_CacheParser.php
│ │ ├── Google_CurlIO.php
│ │ ├── Google_HttpRequest.php
│ │ ├── Google_IO.php
│ │ ├── Google_REST.php
│ │ ├── Google_REST.php~
│ │ └── cacerts.pem
│ └── service
│ │ ├── Google_BatchRequest.php
│ │ ├── Google_MediaFileUpload.php
│ │ ├── Google_Model.php
│ │ ├── Google_Service.php
│ │ ├── Google_ServiceResource.php
│ │ └── Google_Utils.php
├── static
│ └── Credentials.png
└── test
│ ├── AllTests.php
│ ├── BaseTest.php
│ ├── README
│ ├── adsense
│ └── AdSenseTest.php
│ ├── general
│ ├── ApiBatchRequestTest.php
│ ├── ApiCacheParserTest.php
│ ├── ApiClientTest.php
│ ├── ApiMediaFileUploadTest.php
│ ├── ApiModelTest.php
│ ├── ApiOAuth2Test.php
│ ├── AuthTest.php
│ ├── CacheTest.php
│ ├── GeneralTests.php
│ ├── IoTest.php
│ ├── OAuthHelper.php
│ ├── RestTest.php
│ ├── ServiceTest.php
│ └── testdata
│ │ └── test_public_key.pem
│ ├── pagespeed
│ ├── AllPageSpeedTests.php
│ └── PageSpeedTest.php
│ ├── phpunit.xml
│ ├── plus
│ └── PlusTest.php
│ ├── tasks
│ ├── AllTasksTests.php
│ └── TasksTest.php
│ └── urlshortener
│ ├── AllUrlShortenerTests.php
│ └── UrlShortenerTests.php
├── index.php
└── index.phtml
/README.md:
--------------------------------------------------------------------------------
1 | Google-Drive-PHP-API-Simple-App-Example
2 | =======================================
3 |
4 | A very simple File Upload to Google Drive app sample powered with PHP.
5 |
6 | This is the source code I have developed to write the article "Subiendo archivos a Google Drive con PHP" available at http://www.eduardocasas.com/blog/05-12-2012/subiendo-archivos-a-google-drive-con-php
--------------------------------------------------------------------------------
/files/example.txt:
--------------------------------------------------------------------------------
1 | Hello World!
2 |
--------------------------------------------------------------------------------
/google-api-php-client/NOTICE:
--------------------------------------------------------------------------------
1 | This product contains the following libraries:
2 |
3 | XRDS-Simple library from http://code.google.com/p/diso/
4 | Apache License 2.0
5 |
--------------------------------------------------------------------------------
/google-api-php-client/README:
--------------------------------------------------------------------------------
1 | Google APIs Client Library for PHP
2 | =====================================
3 |
4 | == Description
5 | The Google API Client Library enables you to work with Google APIs such as Google+, Drive, Tasks, or Latitude on your server.
6 |
7 | Requirements:
8 | PHP 5.2.x or higher [http://www.php.net/]
9 | PHP Curl extension [http://www.php.net/manual/en/intro.curl.php]
10 | PHP JSON extension [http://php.net/manual/en/book.json.php]
11 |
12 | Project page:
13 | http://code.google.com/p/google-api-php-client
14 |
15 | OAuth 2 instructions:
16 | http://code.google.com/p/google-api-php-client/wiki/OAuth2
17 |
18 | Report a defect or feature request here:
19 | http://code.google.com/p/google-api-php-client/issues/entry
20 |
21 | Subscribe to project updates in your feed reader:
22 | http://code.google.com/feeds/p/google-api-php-client/updates/basic
23 |
24 | Supported sample applications:
25 | http://code.google.com/p/google-api-php-client/wiki/Samples
26 |
27 | == Basic Example
28 | 'free-ebooks');
36 | $results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
37 |
38 | foreach ($results['items'] as $item) {
39 | print($item['volumeInfo']['title'] . '
');
40 | }
41 |
--------------------------------------------------------------------------------
/google-api-php-client/examples/adexchangebuyer/examples/GetAllAccounts.php:
--------------------------------------------------------------------------------
1 | service->accounts->listAccounts();
35 |
36 | print '
No direct deals found
'; 37 | return; 38 | } 39 | foreach ($result['direct_deals'] as $directDeal) { 40 | $this->printResult($directDeal); 41 | } 42 | } 43 | 44 | /** 45 | * (non-PHPdoc) 46 | * @see BaseExample::getName() 47 | * @return string 48 | */ 49 | public function getName() { 50 | return "Get Direct Deals"; 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /google-api-php-client/examples/adexchangebuyer/examples/UpdateAccount.php: -------------------------------------------------------------------------------- 1 | 'account_id', 37 | 'display' => 'Account id to update', 38 | 'required' => true), 39 | array('name' => 'cookie_matching_url', 40 | 'display' => 'New cookie matching URL', 41 | 'required' => true)); 42 | } 43 | 44 | /** 45 | * (non-PHPdoc) 46 | * @see BaseExample::run() 47 | */ 48 | public function run() { 49 | $values = $this->formValues; 50 | $account = new Google_Account(); 51 | $account->setId($values['account_id']); 52 | $account->setCookieMatchingUrl($values['cookie_matching_url']); 53 | 54 | $account = $this->service->accounts->patch($values['account_id'], 55 | $account); 56 | print '" . print_r($publishers, true) . ""; 51 | print "
" . print_r($advertisers, true) . ""; 52 | 53 | // The access token may have been updated lazily. 54 | $_SESSION['access_token'] = $client->getAccessToken(); 55 | } else { 56 | $authUrl = $client->createAuthUrl(); 57 | } 58 | 59 | if(isset($authUrl)) { 60 | print "Connect Me!"; 61 | } else { 62 | print "Logout"; 63 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/analytics/demo/storage.php: -------------------------------------------------------------------------------- 1 | setApplicationName("Google Analytics PHP Starter Application"); 8 | 9 | // Visit https://code.google.com/apis/console?api=analytics to generate your 10 | // client id, client secret, and to register your redirect uri. 11 | // $client->setClientId('insert_your_oauth2_client_id'); 12 | // $client->setClientSecret('insert_your_oauth2_client_secret'); 13 | // $client->setRedirectUri('insert_your_oauth2_redirect_uri'); 14 | // $client->setDeveloperKey('insert_your_developer_key'); 15 | $service = new Google_AnalyticsService($client); 16 | 17 | if (isset($_GET['logout'])) { 18 | unset($_SESSION['token']); 19 | } 20 | 21 | if (isset($_GET['code'])) { 22 | $client->authenticate(); 23 | $_SESSION['token'] = $client->getAccessToken(); 24 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 25 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 26 | } 27 | 28 | if (isset($_SESSION['token'])) { 29 | $client->setAccessToken($_SESSION['token']); 30 | } 31 | 32 | if ($client->getAccessToken()) { 33 | $props = $service->management_webproperties->listManagementWebproperties("~all"); 34 | print "
" . print_r($props, true) . ""; 35 | 36 | $accounts = $service->management_accounts->listManagementAccounts(); 37 | print "
" . print_r($accounts, true) . ""; 38 | 39 | $segments = $service->management_segments->listManagementSegments(); 40 | print "
" . print_r($segments, true) . ""; 41 | 42 | $goals = $service->management_goals->listManagementGoals("~all", "~all", "~all"); 43 | print "
" . print_r($goals, true) . ""; 44 | 45 | $_SESSION['token'] = $client->getAccessToken(); 46 | } else { 47 | $authUrl = $client->createAuthUrl(); 48 | print "Connect Me!"; 49 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/batch.php: -------------------------------------------------------------------------------- 1 | setApplicationName("Google+ PHP Starter Application"); 24 | $plus = new Google_PlusService($client); 25 | 26 | // Visit https://code.google.com/apis/console?api=plus to generate your 27 | // client id, client secret, and to register your redirect uri. 28 | // $client->setClientId('insert_your_oauth2_client_id'); 29 | // $client->setClientSecret('insert_your_oauth2_client_secret'); 30 | // $client->setRedirectUri('insert_your_oauth2_redirect_uri'); 31 | // $client->setDeveloperKey('insert_your_developer_key'); 32 | 33 | if (isset($_GET['logout'])) { 34 | unset($_SESSION['token']); 35 | } 36 | 37 | if (isset($_GET['code'])) { 38 | $client->authenticate(); 39 | $_SESSION['token'] = $client->getAccessToken(); 40 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 41 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 42 | } 43 | 44 | if (isset($_SESSION['token'])) { 45 | $client->setAccessToken($_SESSION['token']); 46 | } 47 | 48 | if ($client->getAccessToken()) { 49 | $client->setUseBatch(true); 50 | 51 | $batch = new Google_BatchRequest(); 52 | $batch->add($plus->people->get('me'), 'key1'); 53 | $batch->add($plus->people->get('me'), 'key2'); 54 | $result = $batch->execute(); 55 | print "
" . print_r($result, true) . ""; 56 | 57 | // The access token may have been updated lazily. 58 | $_SESSION['token'] = $client->getAccessToken(); 59 | } else { 60 | $authUrl = $client->createAuthUrl(); 61 | print "Connect Me!"; 62 | } 63 | -------------------------------------------------------------------------------- /google-api-php-client/examples/books/books_browser.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: white; 3 | color: black; 4 | font-family: Arial, sans-serif; 5 | font-size: small; 6 | margin: 8px; 7 | margin-top: 3px; 8 | } 9 | 10 | .thumbnail img { 11 | border-color:black; 12 | border-style:solid; 13 | } 14 | 15 | table { 16 | border-collapse: collapse; 17 | } 18 | 19 | th, td { 20 | padding: 0; 21 | vertical-align: top; 22 | text-align: left; 23 | font-size: small; 24 | } 25 | 26 | a:link { 27 | color: #0000cc; 28 | } 29 | 30 | a:active { 31 | color: #cc0000; 32 | } 33 | 34 | a:visited { 35 | color: #551a8b; 36 | } 37 | 38 | h1 { 39 | font-size: x-large; 40 | margin-top: 0px; 41 | margin-bottom: 5px; 42 | } 43 | 44 | h2 { 45 | font-size: large; 46 | } 47 | 48 | form { 49 | display: inline; 50 | margin: 0; 51 | padding: 0; 52 | } 53 | 54 | .volumeList td { 55 | padding-bottom: 5px; 56 | padding-right: 5px; 57 | } 58 | 59 | #titleBar { 60 | border: 1px solid silver; 61 | background-color: #e5ecf9; 62 | font-size: large; 63 | font-weight: bold; 64 | margin: 0; 65 | padding: 0; 66 | padding-top: 5px; 67 | padding-bottom: 10px; 68 | padding-left: 10px; 69 | padding-right: 10px; 70 | margin-top: 5px; 71 | margin-bottom: 15px; 72 | } 73 | 74 | #titleText { 75 | float: left; 76 | } 77 | 78 | #mainSearchBox { 79 | background-color: #e5ecf9; 80 | border: 1px solid silver; 81 | width: 300; 82 | padding-top: 5px; 83 | padding-bottom: 10px; 84 | padding-left: 10px; 85 | padding-right: 10px; 86 | } 87 | 88 | #searchResults { 89 | width: 100%; 90 | } 91 | 92 | .volumeList td 93 | { 94 | border-top: 1px solid #aaaaaa; 95 | padding: 6px; 96 | } 97 | 98 | .thumbnail 99 | { 100 | height: 80px; 101 | padding: 3px; 102 | } 103 | 104 | .previewbutton 105 | { 106 | border: 0px; 107 | margin: 6px 0px 6px 0px; 108 | } 109 | 110 | #resultcell 111 | { 112 | padding-right: 20px; 113 | } 114 | 115 | #previewcell 116 | { 117 | border-left: 1px dotted #aaa; 118 | padding-left: 20px; 119 | display: none; 120 | padding-right: 20px; 121 | } 122 | 123 | #viewport { 124 | height: 500px; 125 | width: 100%; 126 | border: 1px solid #aaa; 127 | } 128 | 129 | /* Google Preview: Boilerplate styling */ 130 | #viewport { font-size: 16px; line-height: 1; } 131 | #viewport img, #viewport table, #viewport div, #viewport td 132 | { border: 0; padding: 0; margin: 0; background: none } 133 | #viewport td { vertical-align: middle } -------------------------------------------------------------------------------- /google-api-php-client/examples/books/interface.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 17 | 18 | 19 |
" . print_r($calList, true) . ""; 33 | 34 | 35 | $_SESSION['token'] = $client->getAccessToken(); 36 | } else { 37 | $authUrl = $client->createAuthUrl(); 38 | print "Connect Me!"; 39 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/contacts/simple.php: -------------------------------------------------------------------------------- 1 | setApplicationName('Google Contacts PHP Sample'); 23 | $client->setScopes("http://www.google.com/m8/feeds/"); 24 | // Documentation: http://code.google.com/apis/gdata/docs/2.0/basics.html 25 | // Visit https://code.google.com/apis/console?api=contacts to generate your 26 | // oauth2_client_id, oauth2_client_secret, and register your oauth2_redirect_uri. 27 | // $client->setClientId('insert_your_oauth2_client_id'); 28 | // $client->setClientSecret('insert_your_oauth2_client_secret'); 29 | // $client->setRedirectUri('insert_your_redirect_uri'); 30 | // $client->setDeveloperKey('insert_your_developer_key'); 31 | 32 | if (isset($_GET['code'])) { 33 | $client->authenticate(); 34 | $_SESSION['token'] = $client->getAccessToken(); 35 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 36 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 37 | } 38 | 39 | if (isset($_SESSION['token'])) { 40 | $client->setAccessToken($_SESSION['token']); 41 | } 42 | 43 | if (isset($_REQUEST['logout'])) { 44 | unset($_SESSION['token']); 45 | $client->revokeToken(); 46 | } 47 | 48 | if ($client->getAccessToken()) { 49 | $req = new Google_HttpRequest("https://www.google.com/m8/feeds/contacts/default/full"); 50 | $val = $client->getIo()->authenticatedRequest($req); 51 | 52 | // The contacts api only returns XML responses. 53 | $response = json_encode(simplexml_load_string($val->getResponseBody())); 54 | print "
" . print_r(json_decode($response, true), true) . ""; 55 | 56 | // The access token may have been updated lazily. 57 | $_SESSION['token'] = $client->getAccessToken(); 58 | } else { 59 | $auth = $client->createAuthUrl(); 60 | } 61 | 62 | if (isset($auth)) { 63 | print "Connect Me!"; 64 | } else { 65 | print "Logout"; 66 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/customSearch/index.php: -------------------------------------------------------------------------------- 1 | setApplicationName('Google CustomSearch PHP Starter Application'); 23 | // Docs: http://code.google.com/apis/customsearch/v1/using_rest.html 24 | // Visit https://code.google.com/apis/console?api=customsearch to generate 25 | // your developer key (simple api key). 26 | // $client->setDeveloperKey('INSERT_your_developer_key'); 27 | $search = new Google_CustomsearchService($client); 28 | 29 | 30 | // Example executing a search with your custom search id. 31 | $result = $search->cse->listCse('burrito', array( 32 | 'cx' => 'INSERT_SEARCH_ENGINE_ID', // The custom search engine ID to scope this search query. 33 | )); 34 | print "
" . print_r($result, true) . ""; 35 | 36 | // Example executing a search with the URL of a linked custom search engine. 37 | $result = $search->cse->listCse('burrito', array( 38 | 'cref' => 'http://www.google.com/cse/samples/vegetarian.xml', 39 | )); 40 | print "
" . print_r($result, true) . ""; -------------------------------------------------------------------------------- /google-api-php-client/examples/latitude/index.php: -------------------------------------------------------------------------------- 1 | setClientId('insert_your_oauth2_client_id'); 26 | // $client->setClientSecret('insert_your_oauth2_client_secret'); 27 | // $client->setRedirectUri('insert_your_oauth2_redirect_uri'); 28 | $client->setApplicationName("Latitude_Example_App"); 29 | $service = new Google_LatitudeService($client); 30 | 31 | if (isset($_REQUEST['logout'])) { 32 | unset($_SESSION['access_token']); 33 | } 34 | 35 | if (isset($_GET['code'])) { 36 | $client->authenticate($_GET['code']); 37 | $_SESSION['access_token'] = $client->getAccessToken(); 38 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 39 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 40 | } 41 | 42 | if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { 43 | $client->setAccessToken($_SESSION['access_token']); 44 | } else { 45 | $authUrl = $client->createAuthUrl(); 46 | } 47 | 48 | if ($client->getAccessToken()) { 49 | // Start to make API requests. 50 | //$location = $service->location->listLocation(); 51 | $currentLocation = $service->currentLocation->get(); 52 | $_SESSION['access_token'] = $client->getAccessToken(); 53 | } 54 | ?> 55 | 56 | 57 | 58 | 59 |
Created an AddActivity moment
'; 83 | 84 | $_SESSION['token'] = $client->getAccessToken(); 85 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/pagespeed/index.php: -------------------------------------------------------------------------------- 1 | setApplicationName("PageSpeedOnline_Example_App"); 23 | $service = new Google_PagespeedonlineService($client); 24 | 25 | if (isset($_GET['url'])) { 26 | $result = $service->pagespeedapi->runpagespeed($_GET['url']); 27 | } 28 | ?> 29 | 30 | 31 | 32 | 33 |" . print_r($me, true) . ""; 38 | 39 | $params = array('maxResults' => 100); 40 | $activities = $plus->activities->listActivities('me', 'public', $params); 41 | print "Your Activities:
" . print_r($activities, true) . ""; 42 | 43 | $params = array( 44 | 'orderBy' => 'best', 45 | 'maxResults' => '20', 46 | ); 47 | $results = $plus->activities->search('Google+ API', $params); 48 | foreach($results['items'] as $result) { 49 | print "Search Result:
{$result['object']['content']}\n"; 50 | } 51 | 52 | // The access token may have been updated lazily. 53 | $_SESSION['token'] = $client->getAccessToken(); 54 | } else { 55 | $state = mt_rand(); 56 | $client->setState($state); 57 | $_SESSION['state'] = $state; 58 | 59 | $authUrl = $client->createAuthUrl(); 60 | print "Connect Me!"; 61 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/plus/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | body { 16 | font-family: Arial,sans-serif; 17 | margin: auto; 18 | } 19 | 20 | .box { 21 | border: .5em solid #E3E9FF; 22 | -webkit-box-orient: vertical; 23 | -webkit-box-align: center; 24 | -moz-box-orient: vertical; 25 | -moz-box-align: center; 26 | display: block; 27 | box-orient: vertical; 28 | box-align: center; 29 | width: 350px; 30 | height: auto; 31 | margin: auto; 32 | padding: 10px; 33 | word-wrap: break-word; 34 | text-overflow: ellipsis; 35 | } 36 | 37 | .me { 38 | -webkit-box-flex: 1; 39 | -moz-box-flex: 1; 40 | box-flex: 1; 41 | width: 100px; 42 | } 43 | 44 | .activities { 45 | -webkit-box-flex: 2; 46 | -moz-box-flex: 2; 47 | box-flex: 2; 48 | width:100%; 49 | } 50 | 51 | .activity { 52 | margin: 10px; 53 | } 54 | 55 | header { 56 | color:#000; 57 | padding:2px 5px; 58 | font-size:100%; 59 | width: 400px; 60 | margin: auto; 61 | text-align: center 62 | } 63 | 64 | header h1.logo { 65 | margin:6px 0; 66 | padding:0; 67 | cursor:pointer; 68 | font-size:24px; 69 | line-height:20px; 70 | } 71 | 72 | .login { 73 | font-size: 200%; 74 | display: block; 75 | margin: auto; 76 | cursor: pointer; 77 | text-align: center; 78 | font-weight: bold; 79 | color: #2779AA; 80 | line-height: normal; 81 | } 82 | 83 | .logout { 84 | font-weight: normal; 85 | padding-top: -5px; 86 | margin-top: 0px; 87 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/prediction/README: -------------------------------------------------------------------------------- 1 | Google Prediction API PHP Starter Application 2 | ===================================== 3 | 4 | == Description 5 | This application helps you get started writing a Google Prediction API 6 | PHP application. It's based on a similar app written for the Google+ API. 7 | 8 | Requirements: 9 | PHP 5.2.x or higher [http://www.php.net/] 10 | 11 | Getting Started: 12 | 1) Visit https://code.google.com/apis/console/?api=prediction to 13 | register your application. 14 | 15 | - From the "Sevices" tab, activate access to "Prediction API". 16 | - Click on "API Access" in the left column 17 | - Click the button labeled "Create an OAuth2 client ID" 18 | - Give your application a name and click "Next" 19 | - Select "Web Application" as the "Application type" 20 | - click "Create client ID" 21 | - click "Edit..." for your new client ID 22 | - Under the callback URL, enter the location of your PHP application. 23 | 24 | 2) Update index.php with the redirect uri, client ID, client secret, and 25 | API key you obtained in step 1. 26 | 27 | - Update 'insert_your_oauth2_client_id' with your oauth2 client id. 28 | - Update 'insert_your_oauth2_client_secret' with your oauth2 client secret. 29 | - Update 'insert_your_oauth2_redirect_uri' with the fully qualified 30 | redirect URI. 31 | - Update 'insert_your_developer_key' with your developer key. 32 | 33 | The API key is listed under "Simple API Access" section at the bottom 34 | of the Google API Console site under the API Access tab. 35 | 36 | 3) You are now ready to load index.php on your web server. 37 | 38 | OAuth 2.0 instructions: 39 | http://code.google.com/p/google-api-php-client/wiki/OAuth2 40 | 41 | Supported sample applications: 42 | http://code.google.com/p/google-api-php-client/wiki/Samples 43 | -------------------------------------------------------------------------------- /google-api-php-client/examples/prediction/index.php: -------------------------------------------------------------------------------- 1 | setApplicationName("Google Prediction API PHP Starter Application"); 26 | // Visit https://code.google.com/apis/console/?api=prediction to generate 27 | // your oauth2_client_id, oauth2_client_secret, and to register your 28 | // oauth2_redirect_uri. 29 | // $client->setClientId('insert_your_oauth2_client_id'); 30 | // $client->setClientSecret('insert_your_oauth2_client_secret'); 31 | // $client->setRedirectUri('insert_your_oauth2_redirect_uri'); 32 | // $client->setDeveloperKey('insert_your_developer_key'); 33 | $client->setScopes(array('https://www.googleapis.com/auth/prediction')); 34 | 35 | $predictionService = new Google_PredictionService($client); 36 | $trainedmodels = $predictionService->trainedmodels; 37 | 38 | if (isset($_REQUEST['logout'])) { 39 | unset($_SESSION['access_token']); 40 | } 41 | 42 | if (isset($_GET['code'])) { 43 | $client->authenticate(); 44 | $_SESSION['access_token'] = $client->getAccessToken(); 45 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 46 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 47 | } 48 | 49 | if (isset($_SESSION['access_token'])) { 50 | $client->setAccessToken($_SESSION['access_token']); 51 | } 52 | 53 | if ($client->getAccessToken()) { 54 | $status = "Logged In"; 55 | } else { 56 | $status = "Logged Out"; 57 | $authUrl = $client->createAuthUrl(); 58 | } 59 | ?> 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 |
' . print_r($result, true) . ''; 64 | 65 | // We're not done yet. Remember to update the cached access token. 66 | // Remember to replace $_SESSION with a real database or memcached. 67 | if ($client->getAccessToken()) { 68 | $_SESSION['token'] = $client->getAccessToken(); 69 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/prediction/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | body { 16 | font-family: Arial,sans-serif; 17 | margin: auto; 18 | } 19 | 20 | .box { 21 | border: .5em solid #E3E9FF; 22 | -webkit-box-orient: vertical; 23 | -webkit-box-align: center; 24 | -moz-box-orient: vertical; 25 | -moz-box-align: center; 26 | display: block; 27 | box-orient: vertical; 28 | box-align: center; 29 | width: 350px; 30 | height: auto; 31 | margin: auto; 32 | padding: 10px; 33 | word-wrap: break-word; 34 | text-overflow: ellipsis; 35 | } 36 | 37 | .me { 38 | -webkit-box-flex: 1; 39 | -moz-box-flex: 1; 40 | box-flex: 1; 41 | width: 100px; 42 | } 43 | 44 | .activities { 45 | -webkit-box-flex: 2; 46 | -moz-box-flex: 2; 47 | box-flex: 2; 48 | width:100%; 49 | } 50 | 51 | .activity { 52 | margin: 10px; 53 | } 54 | 55 | header { 56 | color:#000; 57 | padding:2px 5px; 58 | font-size:100%; 59 | width: 400px; 60 | margin: auto; 61 | text-align: center 62 | } 63 | 64 | header h1.logo { 65 | margin:6px 0; 66 | padding:0; 67 | cursor:pointer; 68 | font-size:24px; 69 | line-height:20px; 70 | } 71 | 72 | .login { 73 | font-size: 200%; 74 | display: block; 75 | margin: auto; 76 | cursor: pointer; 77 | text-align: center; 78 | font-weight: bold; 79 | color: #2779AA; 80 | line-height: normal; 81 | } 82 | 83 | .logout { 84 | font-weight: normal; 85 | padding-top: -5px; 86 | margin-top: 0px; 87 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/shopping/simple.php: -------------------------------------------------------------------------------- 1 | setApplicationName("Google Shopping PHP Starter Application"); 7 | 8 | // Visit https://code.google.com/apis/console?api=shopping to generate your 9 | // Simple API Key. 10 | //$client->setDeveloperKey('insert_your_api_key'); 11 | $service = new Google_ShoppingService($client); 12 | 13 | // Valid source values are "public", "cx:cse", and "gan:pid" 14 | // See http://code.google.com/apis/shopping/search/v1/getting_started.html#products-feed 15 | $source = "public"; 16 | 17 | // For more information about full text search with the shopping API, please 18 | // see http://code.google.com/apis/shopping/search/v1/getting_started.html#text-search 19 | $query = "\"mp3 player\" | ipod"; 20 | 21 | //The order in which the API returns products is defined by a ranking criterion. 22 | // See http://code.google.com/apis/shopping/search/v1/getting_started.html#ranking 23 | $ranking = "relevancy"; 24 | 25 | $results = $service->products->listProducts($source, array( 26 | "country" => "US", 27 | "q" => $query, 28 | "rankBy" => $ranking, 29 | )); 30 | 31 | print "
" . print_r($results, true) . ""; 32 | -------------------------------------------------------------------------------- /google-api-php-client/examples/siteVerification/simple.php: -------------------------------------------------------------------------------- 1 | setApplicationName("Google Site Verification PHP Sample"); 8 | 9 | // Visit https://code.google.com/apis/console?api=siteVerification to generate 10 | // your client id, client secret, and to register your redirect uri. 11 | // $client->setClientId('insert_your_oauth2_client_id'); 12 | // $client->setClientSecret('insert_your_oauth2_client_secret'); 13 | // $client->setRedirectUri('insert_your_oauth2_redirect_uri'); 14 | // $client->setDeveloperKey('insert_your_developer_key'); 15 | $service = new Google_SiteVerificationService($client); 16 | 17 | if (isset($_GET['logout'])) { 18 | unset($_SESSION['token']); 19 | } 20 | 21 | if (isset($_GET['code'])) { 22 | $client->authenticate(); 23 | $_SESSION['token'] = $client->getAccessToken(); 24 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 25 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 26 | } 27 | 28 | if (isset($_SESSION['token'])) { 29 | $client->setAccessToken($_SESSION['token']); 30 | } 31 | 32 | if ($client->getAccessToken()) { 33 | $resources = $service->webResource->listWebResource(); 34 | print '
' . print_r($resources, true) . ''; 35 | 36 | $_SESSION['token'] = $client->getAccessToken(); 37 | } else { 38 | $authUrl = $client->createAuthUrl(); 39 | print "Connect Me!"; 40 | } -------------------------------------------------------------------------------- /google-api-php-client/examples/tasks/css/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011 Google Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | body { 18 | font-family:'Droid Sans', Arial; 19 | font-size:18px; 20 | background:#EEE; 21 | color:#444; 22 | } 23 | 24 | a { 25 | color:#36b; 26 | } 27 | 28 | p, h1, h3 { 29 | font-weight:normal; 30 | margin:10px 0; 31 | padding:0; 32 | } 33 | 34 | h1 { 35 | font-size:30px; 36 | } 37 | 38 | #bottom { 39 | width:800px; 40 | margin:0 auto; 41 | } 42 | 43 | #top { 44 | padding:2px 10px; 45 | font-size:14px; 46 | color:#fff; 47 | border-bottom:1px solid #000; 48 | } 49 | 50 | #top h1.logo { 51 | margin:6px 0; 52 | padding:0; 53 | cursor:pointer; 54 | font-size:24px; 55 | line-height:20px; 56 | } 57 | 58 | #top h1.logo a { 59 | color:#fff; 60 | text-decoration:none; 61 | } 62 | 63 | #bottom { 64 | padding:6px 0 6px 10px; 65 | font-size:11px; 66 | color:#aaa; 67 | } 68 | 69 | #bottom a { 70 | color:#333; 71 | } 72 | 73 | #top { 74 | color:#000; 75 | border:1px solid #ddd; 76 | border-bottom:1px solid #000; 77 | padding:2px 5px; 78 | } 79 | 80 | #top h1.logo a { 81 | color:#000; 82 | } 83 | 84 | #identity { 85 | display:block; 86 | float:right; 87 | padding:0; 88 | margin:0; 89 | vertical-align:super; 90 | } 91 | 92 | #identity img { 93 | width:28px; 94 | height:28px; 95 | } 96 | 97 | img { 98 | border-style:none; 99 | } 100 | #content { 101 | padding:0; 102 | } 103 | 104 | #main { 105 | padding:1px 10px 1px 10px; 106 | margin:0; 107 | } 108 | 109 | #main h3 { 110 | padding:6px 0 2px 0; 111 | margin:0; 112 | } 113 | 114 | #container { 115 | width:990px; 116 | margin:0 auto; 117 | position:relative; 118 | background:white; 119 | border:1px solid #AAA; 120 | border-top:0; 121 | -webkit-box-shadow:#CCC 4px 0px 10px, #CCC -4px 0px 10px, #AAA 0px 38px 36px -24px; 122 | -moz-box-shadow:#CCC 4px 0px 10px, #CCC -4px 0px 10px, #AAA 0px 38px 36px -24px; 123 | box-shadow:#CCC 4px 0px 10px, #CCC -4px 0px 10px, #AAA 0px 38px 36px -24px; 124 | overflow:hidden; 125 | } 126 | 127 | #image { 128 | background:white; 129 | border:1px solid #2276BB; 130 | display:block; 131 | float:left; 132 | margin:0 10px 10px 0; 133 | overflow:hidden; 134 | } 135 | 136 | #task { 137 | background:white; 138 | border:1px solid #999; 139 | clear:left; 140 | font-size:1.2em; 141 | margin-bottom:5px; 142 | padding:8px; 143 | -moz-border-radius:5px; 144 | -webkit-border-radius:5px; 145 | } 146 | -------------------------------------------------------------------------------- /google-api-php-client/examples/tasks/index.php: -------------------------------------------------------------------------------- 1 | setClientId('insert_your_oauth2_client_id'); 25 | // $client->setClientSecret('insert_your_oauth2_client_secret'); 26 | // $client->setRedirectUri('insert_your_oauth2_redirect_uri'); 27 | // $client->setApplicationName("Tasks_Example_App"); 28 | $tasksService = new Google_TasksService($client); 29 | 30 | if (isset($_REQUEST['logout'])) { 31 | unset($_SESSION['access_token']); 32 | } 33 | 34 | if (isset($_SESSION['access_token'])) { 35 | $client->setAccessToken($_SESSION['access_token']); 36 | } else { 37 | $client->setAccessToken($client->authenticate($_GET['code'])); 38 | $_SESSION['access_token'] = $client->getAccessToken(); 39 | } 40 | 41 | if (isset($_GET['code'])) { 42 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 43 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 44 | } 45 | ?> 46 | 47 | 48 | 49 |
" . print_r($langs, true) . ""; 15 | 16 | $translations = $service->translations->listTranslations('Hello', 'hi'); 17 | print "
" . print_r($translations, true) . ""; 18 | -------------------------------------------------------------------------------- /google-api-php-client/examples/urlshortener/index.php: -------------------------------------------------------------------------------- 1 | setClientId('insert_your_oauth2_client_id'); 26 | //$client->setClientSecret('insert_your_oauth2_client_secret'); 27 | //$client->setRedirectUri('insert_your_oauth2_redirect_uri'); 28 | $service = new Google_UrlshortenerService($client); 29 | 30 | if (isset($_REQUEST['logout'])) { 31 | unset($_SESSION['access_token']); 32 | } 33 | 34 | if (isset($_GET['code'])) { 35 | $client->authenticate(); 36 | $_SESSION['access_token'] = $client->getAccessToken(); 37 | $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; 38 | header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); 39 | } 40 | 41 | if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { 42 | $client->setAccessToken($_SESSION['access_token']); 43 | } else { 44 | $authUrl = $client->createAuthUrl(); 45 | } 46 | 47 | if ($client->getAccessToken() && isset($_GET['url'])) { 48 | // Start to make API requests. 49 | $url = new Google_Url(); 50 | $url->longUrl = $_GET['url']; 51 | $short = $service->url->insert($url); 52 | $_SESSION['access_token'] = $client->getAccessToken(); 53 | } 54 | ?> 55 | 56 | 57 | 58 | 59 |
" . print_r($fonts, true) . ""; 14 | -------------------------------------------------------------------------------- /google-api-php-client/makeRelease.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION=0.6.0 4 | TMPDIR=/tmp/google-api-php-client 5 | RELFILE=/tmp/google-api-php-client-${VERSION}.tar.gz 6 | 7 | rm -f $RELFILE 8 | rm -rf $TMPDIR 9 | mkdir $TMPDIR 10 | cp -r * $TMPDIR 11 | cd $TMPDIR 12 | find . -name ".*" -exec rm -rf {} \; &>/dev/null 13 | find . -name "makeRelease.sh" -exec rm -rf {} \; &>/dev/null 14 | find . -name "local_*" -exec rm -rf {} \; &>/dev/null 15 | find . -name "static" -exec rm -rf {} \; &>/dev/null 16 | find . -name ".idea" -exec rm -rf {} \; &>/dev/null 17 | cd .. 18 | tar c google-api-php-client | gzip > $RELFILE 19 | rm -rf $TMPDIR 20 | -------------------------------------------------------------------------------- /google-api-php-client/src/auth/Google_AssertionCredentials.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Google_AssertionCredentials { 24 | const MAX_TOKEN_LIFETIME_SECS = 3600; 25 | 26 | public $serviceAccountName; 27 | public $scopes; 28 | public $privateKey; 29 | public $privateKeyPassword; 30 | public $assertionType; 31 | public $prn; 32 | 33 | /** 34 | * @param $serviceAccountName 35 | * @param $scopes array List of scopes 36 | * @param $privateKey 37 | * @param string $privateKeyPassword 38 | * @param string $assertionType 39 | * @param bool|string $prn The email address of the user for which the 40 | * application is requesting delegated access. 41 | */ 42 | public function __construct( 43 | $serviceAccountName, 44 | $scopes, 45 | $privateKey, 46 | $privateKeyPassword = 'notasecret', 47 | $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer', 48 | $prn = false) { 49 | $this->serviceAccountName = $serviceAccountName; 50 | $this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes); 51 | $this->privateKey = $privateKey; 52 | $this->privateKeyPassword = $privateKeyPassword; 53 | $this->assertionType = $assertionType; 54 | $this->prn = $prn; 55 | } 56 | 57 | public function generateAssertion() { 58 | $now = time(); 59 | 60 | $jwtParams = array( 61 | 'aud' => Google_OAuth2::OAUTH2_TOKEN_URI, 62 | 'scope' => $this->scopes, 63 | 'iat' => $now, 64 | 'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS, 65 | 'iss' => $this->serviceAccountName, 66 | ); 67 | 68 | if ($this->prn !== false) { 69 | $jwtParams['prn'] = $this->prn; 70 | } 71 | 72 | return $this->makeSignedJwt($jwtParams); 73 | } 74 | 75 | /** 76 | * Creates a signed JWT. 77 | * @param array $payload 78 | * @return string The signed JWT. 79 | */ 80 | private function makeSignedJwt($payload) { 81 | $header = array('typ' => 'JWT', 'alg' => 'RS256'); 82 | 83 | $segments = array( 84 | Google_Utils::urlSafeB64Encode(json_encode($header)), 85 | Google_Utils::urlSafeB64Encode(json_encode($payload)) 86 | ); 87 | 88 | $signingInput = implode('.', $segments); 89 | $signer = new Google_P12Signer($this->privateKey, $this->privateKeyPassword); 90 | $signature = $signer->sign($signingInput); 91 | $segments[] = Google_Utils::urlSafeB64Encode($signature); 92 | 93 | return implode(".", $segments); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /google-api-php-client/src/auth/Google_Auth.php: -------------------------------------------------------------------------------- 1 | 24 | * 25 | */ 26 | abstract class Google_Auth { 27 | abstract public function authenticate($service); 28 | abstract public function sign(Google_HttpRequest $request); 29 | abstract public function createAuthUrl($scope); 30 | 31 | abstract public function getAccessToken(); 32 | abstract public function setAccessToken($accessToken); 33 | abstract public function setDeveloperKey($developerKey); 34 | abstract public function refreshToken($refreshToken); 35 | abstract public function revokeToken(); 36 | } 37 | -------------------------------------------------------------------------------- /google-api-php-client/src/auth/Google_AuthNone.php: -------------------------------------------------------------------------------- 1 | 21 | * @author Chirag Shah