【问题标题】:Google Calendar ACL rule with PHP使用 PHP 的 Google 日历 ACL 规则
【发布时间】:2012-04-17 22:07:50
【问题描述】:

为什么它返回这个输出“错误:请求的 URL 返回错误:400”而不是发送请求

$headers = array("授权:GoogleLogin auth=".$this->auth."",
                      "GData 版本:2.0",
                      "传输编码:分块",
                      “内容类型:应用程序/原子+xml”
                      );

    $xmlstr = "<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gAcl='http://schemas.google.com/acl/2007'
                    xmlns:gd='http://schemas.google.com/g/2005'
                    gd:etag='W/\"DU4ERH47eCp7ImA9WxRVEkQ.\"'>
                    <category scheme='http://schemas.google.com/g/2005#kind'
                    term='http://schemas.google.com/acl/2007#accessRule'/>
                    <gAcl:scope type='user' value='$email_id'></gAcl:scope>
                    <gAcl:role value='http://schemas.google.com/gCal/2005#read'></gAcl:role>
                </entry>";

    $url = "http://www.google.com/calendar/feeds/$cal_id/acl/full/user%3A".urlencode($email_id)."";


    curl_setopt($this->curl, CURLOPT_URL, $url);
    curl_setopt($this->curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
    curl_setopt($this->curl, CURLOPT_POSTFIELDS, $xmlstr);
    curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($this->curl, CURLOPT_AUTOREFERER, true);
    curl_setopt($this->curl, CURLINFO_HEADER_OUT, false);
    curl_setopt($this->curl, CURLOPT_VERBOSE, true);
    curl_setopt($this->curl, CURLOPT_FAILONERROR, true);
    curl_setopt($this->curl, CURLOPT_COOKIESESSION, true);
    curl_setopt($this->curl, CURLOPT_HEADER, 0);
    curl_setopt($this->curl, CURLOPT_UNRESTRICTED_AUTH, true);

    $response = curl_exec($this->curl);

【问题讨论】:

    标签: php google-calendar-api


    【解决方案1】:

    请注意 PHP API 使用的是 V1,当然是最旧的版本 :( 因此,我们用于更新 ACL 的 xml 与 V2 上的指南略有不同。

    我使用的是:

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

    注意我不要使用“gd:etag”元素。

    其余的xml对你来说是一样的。另一个建议是将您的网址更改为 HTTPS,而不是 HTTP,并添加 'xoauth_requestor_id=' 。 urlencode($USER) 如果需要。

    那么你准备好了,如果有帮助,请告诉我们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-30
      • 1970-01-01
      • 2012-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-18
      相关资源
      最近更新 更多