GData API 共享日历 Zend

发布于 2024-09-27 20:48:41 字数 1969 浏览 10 评论 0原文

嘿,我一直在 Zend 框架内使用 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": "[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."
}

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

任何帮助将不胜感激

Hey I have been playing with the GDATA_Calendar implementation inside the Zend Framework and have been successfully able to create sub calendars.

However, I have been having trouble in dynamically sharing these calendars with users.

Looking over the official Google docs (http://code.google.com/apis/calendar/data/2.0/developers_guide_protocol.html#UpdateAcl) it seems to support changing the ACL on a given calendar to allow sharing with particular users.

Sadly I cannot seem to get this working.

Have even tried spawning my own client and setting the rawdata and enc types but it seems the GDATA implementation is overwriting the content types?

$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);

The resulting response shows

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."
}

As you can see, it doesn't even seem to be accepting the content type specified?

Any help would be greatly appreciated

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

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

发布评论

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

评论(1

み零 2024-10-04 20:48:41
$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 服务对象中找到了这个小函数,并使用它来推送带有标头的所有内容。

希望对某人有帮助

$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);

Well - found the answer.. its finding this little function within the gdata service object and using that to push everything with the headers.

Hope that helps someone

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