Hi all

I'm trying to create a simple script that will retrieve the calendars
feed. I'm using the pecl_http extension for PHP that offers me the
HttpRequest class which is based on curl.

After getting the gsessionid, I try to resend the request after
setting the query param, and cookie, but get a 400 Bad Request.

Any help would be much appreciated.

David.

<?php

session_start();

if (!isset($_SESSION['google_auth']))
{
    $login = array(
        'accountType' => 'HOSTED',
        'Email' => '[email protected]',
        'Passwd' => 'password',
        'service' => 'cl',
        'source' => 'myApp-myEvents-1'
    );

    $request = new HttpRequest('https://www.google.com/accounts/
ClientLogin', HTTP_METH_POST);
    $request->addPostFields($login);
    $response = $request->send();

    if ($response->getResponseCode() == 200)
    {
        $auth = array_pop(explode('Auth=', $response->getBody()));
        $_SESSION['google_auth'] = $auth;
    }
    echo 'getting auth';
}

$request = new HttpRequest('http://www.google.com/calendar/feeds/
default/owncalendars/full', HTTP_METH_GET);
$request->addHeaders(array('Authorization' => 'GoogleLogin auth='.
$_SESSION['google_auth']));
$response = $request->send();

if ($response->getResponseCode() == 302)
{
    $url = explode('?gsessionid=', $response->getHeader('Location'));
    $location = $url[0];
    $cookie = $url[1];
    $request = new HttpRequest($location, HTTP_METH_GET);
    $request->addHeaders(array('Authorization' => 'GoogleLogin auth='.
$_SESSION['google_auth']));
    $request->setCookies(array('S' => $cookie));
    $request->setQueryData(array('gsessionid' => $cookie));

    $response = $request->send();
    var_dump($response);
}
else
{
    var_dump($response);
}



--~--~---------~--~----~------------~-------~--~----~
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