google drive api anchor在电子表格单元格php上创建评论

时间:2016-02-19 06:35:10

标签: google-drive-api google-api-php-client

我想通过api为谷歌电子表格单元创建评论我该怎么做

我已经通过这样的锚点在电子表格的特定列上插入注释但是它已插入不指向特定列的表单

$APPPATH = dirname(__FILE__).'/google-api-php-client/';
set_include_path(dirname(__FILE__).'/google-api-php-client/src');

require_once 'google-api-php-client/src/Google/autoload.php';


$client_email = 'xxxxx.iam.gserviceaccount.com';
$private_key = file_get_contents('ServiceAccount-062591099ed0.p12');
$scopes = array('https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/drive');
$credentials = new Google_Auth_AssertionCredentials(
    $client_email,
    $scopes,
    $private_key
);
$client = new Google_Client();

$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
  $client->getAuth()->refreshTokenWithAssertion();
}
$service = new Google_Service_Drive($client);

$fileId="xxxxxxxxxxxxxxxxxxxxxxxxx";

$comment_data=new Google_Service_Drive_Comment($client); 
$comment_data->content="hi comment on cell again & again"; 

$revisionId=$service->revisions->get($fileId, "head"); 

$matrix = array('r'=>$revisionId->id,'a'=>array((object)array('matrix'=>array('c'=>2,'r'=>2,'w'=>1,'h'=>1,'mw'=>100,'mh'=>100))));

 $std  = (object) $matrix;
 //echo json_encode($std);die;


$comment_data->anchor = $std; 
$service->comments->create($fileId, $comment_data,array('fields'=>'content'));

0 个答案:

没有答案