2010-10-18 91 views
2

嘿,我一直在玩Zend Framework內的GDATA_Calendar實現,並已成功地創建子日曆。GData API分享日曆Zend

但是,我一直在與用戶動態共享這些日曆時遇到問題。

查看官方的Google文檔(http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#UpdateAcl),它似乎支持更改給定日曆上的ACL以允許與特定用戶。

可悲的是我似乎無法得到這個工作。

甚至嘗試產卵我自己的客戶端,並設置rawdata和enc類型,但它似乎GDATA實現覆蓋的內容類型?

$client = Zend_Gdata_ClientLogin::getHttpClient($this->user, $this->pass, Zend_Gdata_Calendar::AUTH_SERVICE_NAME); 
      $client->setMethod("POST"); 
      $client->setUri($appURL . "?alt=json"); 
      $client->setEncType("application/json"); 
      $client->setRawData('{' 
    . '"data": {' 
    . '"scope": "[email protected]",' 
    . '"scopeType": "user",' 
    . '"role": "editor"' 
    . '}' 
    . '}"', "application/json"); 
      Zend_Debug::dump($client); 
     $response = $client->request(); 


     Zend_Debug::dump($response); 

引起的反應顯示

object(Zend_Http_Response)#558 (5) { 
    ["version":protected] => string(3) "1.1" 
    ["code":protected] => int(415) 
    ["message":protected] => string(22) "Unsupported Media Type" 
    ["headers":protected] => array(9) { 
    ["Content-type"] => string(24) "text/html; charset=UTF-8" 
    ["Date"] => string(29) "Mon, 18 Oct 2010 05:10:23 GMT" 
    ["Expires"] => string(29) "Mon, 18 Oct 2010 05:10:23 GMT" 
    ["Cache-control"] => string(18) "private, max-age=0" 
    ["X-content-type-options"] => string(7) "nosniff" 
    ["X-frame-options"] => string(10) "SAMEORIGIN" 
    ["X-xss-protection"] => string(13) "1; mode=block" 
    ["Server"] => string(3) "GSE" 
    ["Connection"] => string(5) "close" 
    } 
    ["body":protected] => string(73) "Content-Type application/x-www-form-urlencoded is not a valid input type." 
} 

正如你所看到的,它甚至不似乎接受指定的內容類型?

任何幫助,將不勝感激

回答

0
$data = " 
    <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:scope type='user' value='{$accountEmail}'></gAcl:scope> 
     <gAcl:role value='http://schemas.google.com/gCal/2005#editor'> 
     </gAcl:role> 
    </entry> 
"; 

$response = $this->service->post(trim($data), $appURL); 

好 - 找到了答案..其找到GDATA服務對象中的這個小功能,並使用推與頭部的一切。

希望能幫助別人