2012-04-04 1 views
0

Warum es diese Ausgabe gibt „Fehler: Die angeforderte URL einen Fehler zurückgegeben: 400“ statt Anfrage SendenGoogle Calendar ACL-Regel mit 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);

Antwort

1

Bitte beachten Sie PHP API V1 verwendet, natürlich, die älteste Version :( so, die xml wir ACL zu aktualisieren verwenden ist ein wenig anders als die Führung auf V2

Was ich benutze ist:.

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

und t Vorsicht, ich benutze nicht das Element "gd: etag".

Der Rest xml ist das gleiche für Sie. Auch ein anderer Vorschlag ändert Ihre URL zu HTTPS anstelle von HTTP, und fügt 'xoauth_requestor_id =' hinzu. Urlencode ($ USER), falls erforderlich.

Dann sind Sie bereit zu gehen, lassen Sie uns wissen, wenn es hilft.