用PHP

2012-04-04 37 views
0

为什么它返回输出谷歌日历ACL规则“错误:请求的URL返回错误:400”,而不是发送请求用PHP

$headers = array("Authorization: GoogleLogin auth= " . $this->auth . "", 
         "GData-Version: 2.0", 
         "Transfer-Encoding: chunked", 
         "Content-Type: application/atom+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);

回答

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

和T关心我不使用“gd:etag”元素。

剩下的xml和你一样。另外一个建议是将您的网址更改为HTTPS,而不是HTTP,并添加'xoauth_requestor_id ='。 urlencode($ USER),如果需要的话。

然后你准备好了,让我们知道它是否有帮助。