开发者

Google docs POST request

开发者 https://www.devze.com 2023-01-29 18:49 出处:网络
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 fo

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://sch开发者_JS百科emas.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>

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

Thanks in advance


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='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

0

精彩评论

暂无评论...
验证码 换一张
取 消