
Untitled
By: a guest on
Aug 11th, 2012 | syntax:
None | size: 2.01 KB | hits: 6 | expires: Never
Is it possible to use a batch request to create documents and add acl to them in the same request?
<?php
public function batch($content) {
return '<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:docs="http://schemas.google.com/docs/2007"
xmlns:batch="http://schemas.google.com/gdata/batch"
xmlns:gd="http://schemas.google.com/g/2005">' . $content . '</feed>';
}
public function batchCopyAndShare($title, $emails, $role = 'writer', $scope = 'user') {
$url = 'https://docs.google.com/feeds/default/private/full/batch';
$entries = '';
$id = 1;
foreach($emails as $email) {
$entries .= '<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007">' .
"<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/acl/2007#accessRule'/>" .
'<id>https://docs.google.com/feeds/default/private/full/spreadsheet%3A' . $this->id() . '</id>
<title>' . $title . ' - ' . $email . '</title>'
. "<gAcl:role value='$role'/>"
. "<gAcl:scope type='$scope' value='$email'/>"
. "</entry>";
}
$entry = '<?xml version="1.0" encoding="UTF-8"?>' . $this->batch($entries);
$res = (gget('POST', $url, array(), $entry));
return $res;
}
?>
<?php
batchCopyAndShare("title", array("email@address.com"));
?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gd="http://schemas.google.com/g/2005">
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:gAcl="http://schemas.google.com/acl/2007">
<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/acl/2007#accessRule'/>
<id>https://docs.google.com/feeds/default/private/full/spreadsheet%3Adocumentid</id>
<title>title - email@address.com</title>
<gAcl:role value='writer'/>
<gAcl:scope type='user' value='email@address.com'/>
</entry>
</feed>