GData API共享日历Zend

时间:2010-10-18 05:19:50

标签: php zend-framework google-calendar-api zend-gdata

嘿,我一直在使用Zend Framework中的GDATA_Calendar实现,并且已经成功地创建了子日历。

但是,我一直无法与用户动态共享这些日历。

查看官方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": "darcy@gmail.com",'
  . '"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."
}

正如您所看到的,它似乎甚至不接受指定的内容类型?

非常感谢任何帮助

1 个答案:

答案 0 :(得分: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服务对象中发现了这个小函数,并使用它来推送带有标题的所有内容。

希望能帮到某人