Thank You!!!! That worked!!!

On May 14, 3:08 pm, "Austin (Google)" <[EMAIL PROTECTED]> wrote:
> Nice catch Ray!
>
> Also, if your library is handling redirection on your behalf, there is a
> good chance that it is not re-appending the auth token in the header.  In
> this case, you need to disable default behavior of your library to auto
> follow redirect and manually follow redirect as Ray has mentioned with the
> appropriate HTTP method and the auth token.
>
> Hope it helps,
> Austin
>
> On Wed, May 14, 2008 at 2:05 PM, Ray Baxter <[EMAIL PROTECTED]> wrote:
>
> > Interesting case. I see that your code is not explicitly handling the
> > redirect, so that must mean that your library is doing it
> > automatically for you.
>
> > I think what is happening here is that the library you are using is
> > incorrectly issuing a GET on the redirect. This is mentioned in the
> > Google documentation as a common problem and there is an
> > X-If-No-Redirect header that you can set so that the post will not
> > automatically be redirect. You will then have to POST again to the
> > location specified in the response.
>
> > You can read more about this here:
>
> >http://code.google.com/support/bin/answer.py?answer=55833&topic=10360
>
> > Ray
>
> > On Wed, May 14, 2008 at 12:46 PM, Lich <[EMAIL PROTECTED]> wrote:
>
> > > Thank you for your response here is all the code:
>
> > > function GConnect($url, $headers = null, $c_type = null, $body = null,
> > > $timeout = 10, $redirects = 5) {
> > >  $fp = curl_init();
> > >  curl_setopt($fp, CURLOPT_ENCODING, '');
> > >  curl_setopt($fp, CURLOPT_URL, $url);
> > >  curl_setopt($fp, CURLOPT_HEADER, 1);
> > >  curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1);
> > >  curl_setopt($fp, CURLOPT_TIMEOUT, $timeout);
> > >  curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout);
> > >  curl_setopt($fp, CURLOPT_REFERER, $url);
> > >  if (!is_array($headers)) $headers = array();
> > >  if (!is_array($load_headers)) $load_headers = array();
> > >  foreach ($headers as $key => $value) $load_headers[] = "$key:
> > > $value";
> > >  curl_setopt($fp, CURLOPT_HTTPHEADER, $load_headers);
> > >  curl_setopt($fp, CURLOPT_FAILONERROR, 1);
> > >  if ($c_type == 'POST') {
> > >  curl_setopt($fp, CURLOPT_POST, true);
> > >  curl_setopt($fp, CURLOPT_POSTFIELDS, $body);
> > >  }
> > >  if ($c_type == 'PUT') {
> > >  $fdata = tmpfile();
> > >  fwrite($fdata, $body);
> > >  fseek($fdata, 0);
> > >  curl_setopt($fp, CURLOPT_PUT, true);
> > >  curl_setopt($fp, CURLOPT_INFILE, $fdata);
> > >  curl_setopt($fp, CURLOPT_INFILESIZE, strlen($body));
> > >  }
> > >  if ($c_type == 'DELETE') {
> > >  curl_setopt($fp, CURLOPT_CUSTOMREQUEST, "DELETE");
> > >  }
> > >  curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1);
> > >  curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects);
> > >  $response = curl_exec($fp);
> > >  if (curl_errno($fp)) {
> > >  return 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp);
> > >  } else {
> > >  $info = curl_getinfo($fp);
> > >  curl_close($fp);
> > >  }
> > >  return $response;
> > > }
>
> > > // Check for authentication and login
> > > $gcdomain = 'mydomain';
> > > $gcpass = 'pass';
> > > $gcuser = 'admin';
> > > $body = "&Email=".$gcuser."@".$gcdomain."&Passwd=".
> > > $gcpass."&accountType=HOSTED&service=cl";
> > > $url = "https://www.google.com/accounts/ClientLogin";;
> > > $feed = GConnect($url, $header_array, 'POST', $body);
> > > list($headers,$body) = explode("\n\r", $feed);
> > > $body_array = explode("\n", $body);
> > > foreach ($body_array as $body) {
> > >  list($key, $val) = explode('=', $body);
> > >  if ($key == 'Auth') $client = $val;
> > > }
>
> > > // Add Event
> > > $body = "<entry xmlns='http://www.w3.org/2005/Atom'xmlns:gCal='http://
> > > schemas.google.com/gCal/2005'><content type='html'>Tennis with John
> > > May 14 3pm-3:30pm</content><gCal:quickadd value='true'/></entry>";
> > > $header_array = array('Authorization' => "GoogleLogin auth=$client",
> > > 'Content-Type' => 'application/atom+xml');
> > > $url = "http://www.google.com/calendar/feeds/[EMAIL PROTECTED]/private/
> > > full";
> > > $body = preg_replace("/\n/","",$body);
> > > $feed = GConnect($url, $header_array, 'POST', $body);
> > > list($headers,$body) = explode("\n\r", $feed);
> > > print_r($feed);
> > > exit;
>
> > > Here is the output:
>
> > > HTTP/1.1 302 Moved Temporarily
> > > Set-Cookie: S=calendar=ABdRo6Wsej46D3u1OhXQ5Q;Expires=Thu, 14-May-2009
> > > 19:36:01 GMT
> > > Location:
> >http://www.google.com/calendar/feeds/[EMAIL PROTECTED]/private/full?g...
> > > Content-Type: text/html; charset=UTF-8
> > > Date: Wed, 14 May 2008 19:36:01 GMT
> > > Expires: Wed, 14 May 2008 19:36:01 GMT
> > > Cache-Control: private, max-age=0
> > > Transfer-Encoding: chunked
> > > Server: GFE/1.3
>
> > > HTTP/1.1 200 OK
> > > Content-Type: application/atom+xml; charset=UTF-8
> > > Cache-Control: max-age=0, must-revalidate, private
> > > GData-Version: 1.0
> > > Last-Modified: Fri, 09 May 2008 18:53:10 GMT
> > > Transfer-Encoding: chunked
> > > Date: Wed, 14 May 2008 19:36:02 GMT
> > > Server: GFE/1.3
>
> > > <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/
> > > 2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
> > > xmlns:batch='http://schemas.google.com/gdata/batch'xmlns:gCal='http://
> > > schemas.google.com/gCal/2005' xmlns:gd='http://schemas.google.com/g/
> > > 2005'><id>http://www.google.com/calendar/feeds/testuser%40mydomain/
> > > private/full</id><updated>2008-05-09T18:53:10.000Z</updated><category
> > > scheme='http://schemas.google.com/g/2005#kind'term='http://
> > > schemas.google.com/g/2005#event'/<http://schemas.google.com/g/2005#event%27/>><title
> > type='text'>Test Account</
> > > title><subtitle type='text'>Test Account</subtitle><link
> > > rel='alternate' type='text/html' href='http://www.google.com/calendar/
> > > [EMAIL PROTECTED]'/><link rel='http://schemas.google.com/g/
> > > 2005#feed' type='application/atom+xml' href='http://www.google.com/
> > > calendar/feeds/testuser%40mydomain/private/full'/><link rel='http://
> > > schemas.google.com/g/2005#post' type='application/atom+xml'
> > > href='http://www.google.com/calendar/feeds/testuser%40mydomain/private/
> > > full'/><link rel='http://schemas.google.com/g/2005#batch'
> > > type='application/atom+xml' href='http://www.google.com/calendar/feeds/
> > > testuser%40mydomain/private/full/batch'/><link rel='self'
> > > type='application/atom+xml' href='http://www.google.com/calendar/feeds/
> > > testuser%40mydomain/private/full?max-results=25'/><author><name>Test
> > > Account</name><email>[EMAIL PROTECTED]</email></author><generator
> > > version='1.0' uri='http://www.google.com/calendar'>Google Calendar</
> > > generator><openSearch:totalResults>6</
> > > openSearch:totalResults><openSearch:startIndex>1</
> > > openSearch:startIndex><openSearch:itemsPerPage>25</
> > > openSearch:itemsPerPage><gCal:timezone value='America/Denver'/
> > >><entry><id>http://www.google.com/calendar/feeds/testuser%40mydomain/
> > > private/full/98suu0elr9rlkn0nm585jb2d3c</
> > > id><published>2008-05-09T18:50:14.000Z</
> > > published><updated>2008-05-09T18:50:14.000Z</updated><category
> > > scheme='http://schemas.google.com/g/2005#kind'term='http://
> > > schemas.google.com/g/2005#event'/<http://schemas.google.com/g/2005#event%27/>><title
> > type='text'>Test Account</
> > > title><content type='text'/><link rel='alternate' type='text/html'
> > > href='http://www.google.com/calendar/hosted/mydomain/event?
> > > eid=OThzdXUwZWxyOXJsa24wbm01ODVqYjJkM2MgMTUwNjlAbXlyaWNoZGFkZHJlYW0uY29t'
> > > title='alternate'/><link rel='self' type='application/atom+xml'
> > > href='http://www.google.com/calendar/feeds/testuser%40mydomain/private/
> > > full/98suu0elr9rlkn0nm585jb2d3c'/><link rel='edit' type='application/
> > > atom+xml' href='http://www.google.com/calendar/feeds/testuser
> > > %40mydomain/private/full/98suu0elr9rlkn0nm585jb2d3c/63346042214'/
> > >><author><name>Test Account</name><email>[EMAIL PROTECTED]</email></
> > > author><gd:comments><gd:feedLink href='http://www.google.com/calendar/
> > > feeds/testuser%40mydomain/private/full/98suu0elr9rlkn0nm585jb2d3c/
> > > comments'/></gd:comments><gd:eventStatus value='http://
> > > schemas.google.com/g/2005#event.confirmed'/<http://schemas.google.com/g/2005#event.confirmed%27/>
> > ><gd:visibility
> > > value='http://schemas.google.com/g/2005#event.default'/<http://schemas.google.com/g/2005#event.default%27/>
> > >><gd:transparency value='http://schemas.google.com/g/
> > > 2005#event.opaque'/><gCal:uid
> > > value='[EMAIL PROTECTED]'/><gCal:sequence
> > > value='0'/><gd:when startTime='2008-05-10T10:30:00.000-06:00'
> > > endTime='2008-05-10T12:30:00.000-06:00'/><gd:who rel='http://
> > > schemas.google.com/g/2005#event.organizer' valueString='Test Account'
> > > email='[EMAIL PROTECTED]'/><gd:where/></entry><entry><id>http://
>
> >www.google.com/calendar/feeds/testuser%40mydomain/private/full/l99lv6...
> > </id><published>2008-05-08T16:27:35.000Z</published><updated>2008-05-08T16:27:35.000Z</updated><category
> > > scheme='http://schemas.google.com/g/2005#kind'term='http://
> > > schemas.google.com/g/2005#event'/<http://schemas.google.com/g/2005#event%27/>><title
> > type='text'>Sat event</
> > > title><content type='text'/><link rel='alternate' type='text/html'
> > > href='http://www.google.com/calendar/hosted/mydomain/event?
> > > eid=bDk5bHY2MDMyNzQ3bnQ4bXE3am05MDk1bjQgMTUwNjlAbXlyaWNoZGFkZHJlYW0uY29t'
> > > title='alternate'/><link rel='self' type='application/atom+xml'
> > > href='http://www.google.com/calendar/feeds/testuser%40mydomain/private/
> > > full/l99lv6032747nt8mq7jm9095n4'/><link rel='edit' type='application/
> > > atom+xml' href='http://www.google.com/calendar/feeds/testuser
> > > %40mydomain/private/full/l99lv6032747nt8mq7jm9095n4/63345947255'/
> > >><author><name>Test Account</name><email>[EMAIL PROTECTED]</email></
> > > author><gd:comments><gd:feedLink href='http://www.google.com/calendar/
> > > feeds/testuser%40mydomain/private/full/l99lv6032747nt8mq7jm9095n4/
> > > comments'/></gd:comments><gd:eventStatus value='http://
> > > schemas.google.com/g/2005#event.confirmed'/<http://schemas.google.com/g/2005#event.confirmed%27/>
> > ><gd:visibility
>
> ...
>
> read more ยป
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to