2010-12-08 81 views
0

我正在開發一個web應用程序,它通過api與google文檔交互。 作爲Zend_Gdata沒有方法來改變的,我需要使用POST方法和下列文件共享permitions:Google文檔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功能嗎?我應該使用捲曲來做它嗎?如何?

在此先感謝

回答

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