0

我正在开发一个通过 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 来做到这一点吗?如何?

提前致谢

4

1 回答 1

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

于 2011-05-10T12:05:01.743 回答