Google docs POST请求

时间:2010-12-08 18:43:48

标签: google-docs-api

我正在开发一个通过api与谷歌文档交互的网络应用程序。 由于Zend_Gdata没有方法来更改文档的共享权限,我需要使用POST方法,如下所示:

POST /feeds/default/private/full/resource_id/acl HTTP/1.1
Host: docs.google.com
GData-Version: 3.0
Authorization: <your authorization header here>

<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'/>
  <gAcl:role value='writer'/>
  <gAcl:scope type='user' value='new_writer@example.com'/>
</entry>

我到底在哪里这样做? php有POST功能吗?我应该用curl来做吗?怎么样?

提前致谢

1 个答案:

答案 0 :(得分:0)

PHP可以做到一切。

$url = "http://docs.google.com/feeds/default/private/full/resource_id/acl";

$headers = array("GData-Version: 3.0",
"Authorization: <your authorization header here>");

$body = "<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'/>
    <gAcl:role value='writer'/>
    <gAcl:scope type='user' value='new_writer@example.com'/>
  </entry>";

// main options
curl_setopt($this->curl, CURLOPT_URL, $url);
curl_setopt($this->curl, CURLOPT_POST, true);
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
if (!empty($body)) curl_setopt($this->curl, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($this->curl);

http://www.php.net/manual/en/book.curl.php