Hello all,

I have tried all day yesterday to create a calendar both with curl and
fsockets in php (note that ZEND is not an option for me at this time
and I don't believe they allow for creating calendars anyway). I have
tried many variations with setting up my http headers and tried to
RTFM so to speak both in the gdata api docs and anywhere else I can,
but I'm lost as to why I can't get this working. I get 411 even though
I have Content-Length headers, input malformed-like errors, as well as
various other fun errors depending on how I swap these around.
Disclaimer: I usually don't 'hack' this bad, but I'm completely lost
at this point ;)

Question: Does anyone have a 'working' simple example of either using
curl or fsocketopen to create a calendar? Here are the relevent parts
of the code for both that I'm mixed up on:

Curl:
2 attempts at setting the headers:
------------ Attempt 1-variations of the following:
$header  = array(
"POST ".$url . "\r\n" . GDataMappily::
$GOOGLE_AUTHORIZACTION_HEADER_PREFIX . $AuthToken. "\r\n" .
GDataMappily::$GOOGLE_X_IF_NO_REDIRECT. "\r\n" .
GDataMappily::$GOOGLE_CONTENT_TYPE_ATOM_XML . "\r\n" .
"Accept: text/xml" . "\r\n" .
"Content-length: " .strlen($calEntry) . "\r\n\r\n" .
$calEntry);
------------ Attempt 2-and also tried variations that looked like:
$developerKey = MY_LONG_DEV_KEY_IS_HERE
$header  = array(       'Content-Type: application/atom+xml',
'Authorization: AuthSub token="' . $AuthToken . '"',
'X-Google-Key: key=' . $developerKey,
'Content-Length: ' . strlen($calEntry)
);
---------------
//              curl_setopt($ch, CURLOPT_URL, $url);
//              curl_setopt($ch, CURLOPT_HEADER, 1);    // Need this to handle
redirects
//              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//              //curl_setopt($ch, CURLOPT_TIMEOUT, 60);
//              curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
//              curl_setopt($ch, CURLOPT_POSTFIELDS, $calEntry);
//              curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

And then I tried variations of the following with raw headers:

        $host = "www.google.com";
        $path = '/calendar/feeds/default/owncalendars/full';
        $developerKey = MYDEVKEY

        //$out  = "POST " . $path . " HTTP/1.1\r\n";
        $out  = "POST " . $path . "\r\n";
        $out .= "Host: " . $host . "\r\n";
        $out .= "Content-Length: " . strlen($calEntry) . "\r\n";
        $out .= "Authorization: GoogleLogin auth" . '"' . $AuthToken . '"' .
"\r\n";
        $out .= "Content-Type: application/atom+xml\r\n\r\n";
        //$out .= "X-Google-Key: key=" . $developerKey . "\r\n";
        //$out .= "Connection: close\r\n\r\n";
        $out .= $calEntry;

// And then fsocketsopen stuff here

Either help, or even better, a working example of using curl or raw
headers in php (NOT Zend) to create a calendar would be deeply
appreciated! Thanks all.
--~--~---------~--~----~------------~-------~--~----~
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