如何在php中使用oauth分享google文档

时间:2013-06-05 07:11:24

标签: php oauth google-drive-realtime-api

我需要将我的AuthSub代码更改为oAuth,因为Google正在弃用AuthSub。 在我的项目中,用户现在可以使用编写/只读角色创建和共享他的谷歌文档到其他人。

将authsub更改为oauth时,我可以使用oauth代码创建新文档,但我无法将此文档分享给其他用户。

这是我的authsub代码

<?php 

$dataShare="<feed xmlns=\"w3.org/2005/Atom\" xmlns:gAcl='schemas.google.com/acl/2007'; xmlns:batch='schemas.google.com/gdata/batch'>; <category scheme='schemas.google.com/g/2005#kind'; term='schemas.google.com/acl/2007#accessRule'/>";;

$dataShare .= "<entry> 
                    <batch:id>1</batch:id> 
                    <batch:operation type='insert'/> 
                    <gAcl:role value='writer' /> 
                    <gAcl:scope type='user' value='emailid@gmail.com'/> </entry>"; 
$dataShare .= "</feed>"; 

$uri = "docs.google.com/feeds/default/private/full/$newShareDocID/acl/batch";
$headers[]= "Host: docs.google.com"; 
$headers[]= "GData-Version: 3.0"; 
$headers[]= "Content-Type: application/atom+xml"; 
$headers[]= "Authorization: AuthSub token=\"".$_SESSION['docsSampleSessionToken']."\""; 
$a = new cURL($headers); 
$b = $a->post($uri, $dataShare); 

?>

How do I change this sharing code according to oauth. I searched on net but couldn't find anything. Thanks in advance..

0 个答案:

没有答案