-
Notifications
You must be signed in to change notification settings - Fork 1
/
gdatatest.php
57 lines (43 loc) · 1.88 KB
/
gdatatest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
//
define('ROOT_DIR', dirname(__FILE__));
set_include_path('.' . PATH_SEPARATOR . ROOT_DIR . '/library'
. PATH_SEPARATOR . ROOT_DIR . '/library/Zend'
. PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace(array('Models_', 'Zotero_', 'Forms_'));
$loader->setFallbackAutoloader(true);
//$gdata = new Zend_Gdata();
$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$my_docs = 'https://docs.google.com/feeds/default/private/full';
if (!isset($_SESSION['docs_token'])) {
if (isset($_GET['token'])) {
// You can convert the single-use token to a session token.
$session_token =
Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
// Store the session token in our session.
$_SESSION['docs_token'] = $session_token;
} else {
// Display link to generate single-use token
$googleUri = Zend_Gdata_AuthSub::getAuthSubTokenUri(
'http://'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'],
$my_docs, 0, 1);
echo "Click <a href='$googleUri'>here</a> " .
"to authorize this application.";
exit();
}
}
// Create an authenticated HTTP Client to talk to Google.
$client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['docs_token']);
// Create a Gdata object using the authenticated Http Client
//$client = Zend_Gdata_ClientLogin::getHttpClient('username', 'password', $service);
//$gdata = new Zend_Gdata($client);
//$gdata->setMajorProtocolVersion(3);
//$gdata->setMinorProtocolVersion(null);
$docs = new Zend_Gdata_Docs($client);
$newdoc = $docs->uploadFile('/home/fcheslack/Desktop/sports.png', 'Sports', 'image/png', 'https://docs.google.com/feeds/default/private/full?ocr=true');
//$feed = $docs->getDocumentListFeed();
//var_dump($feed->entries);
var_dump($newdoc);
?>