Google 文档 POST 请求

发布于 2024-10-06 20:44:48 字数 804 浏览 0 评论 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='[email protected]'/>
</entry>

我到底在哪里执行此操作? php 有 POST 函数吗?我应该使用curl 来做到这一点吗?又如何呢?

提前致谢

I'm developing a web aplication which interacts with google docs through api.
As Zend_Gdata doesn't have methods to change the sharing permitions of documents I need to use the POST method as the following:

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='[email protected]'/>
</entry>

Where exactly do I do this? Does php has a POST function? Should I use curl to do it? and how?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日暮斜阳 2024-10-13 20:44:48

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='[email protected]'/>
  </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

PHP can everything.

$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='[email protected]'/>
  </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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文