Hi Harish, It's great news that you've been able to successfully acquire an auth token.
It looks like you're re-using the socket currently. Try using a new socket for your GET requests to calendar, as it doesn't look like you're setting a keep-alive header. Using keep-alive is a great bonus if you're looking to eliminate the overhead of the second socket connection-- but probably not helpful when debugging :) Also, SSL is not required for working with the calendar api, other than when retrieving the auth tokens from the auth services. So, you could send plain clear-text data across the wire here and use something like ethereal, wireshark or the like to capture the packets: http://code.google.com/support/bin/answer.py?answer=55856&topic=10362 Let us know how it works out. Cheers, -Ryan On 3/30/07, Harish Kumar Dixit <[EMAIL PROTECTED]> wrote: > > > Hello friend i m trying to access google calendar information > programatically. Now there is how i m doing... > > first i m sending HTTPS POST request , then i will get an Auth token. > By using that token as a header i will make HTTP GET request. now i m > doing same . I m getting Auth token but not getting response for GET > request. here is my code: > > > WORD wVersionRequested; > WSADATA wsaData; > int err; > > wVersionRequested = MAKEWORD( 2, 2 ); > > err = WSAStartup( wVersionRequested, &wsaData ); > > hostent* pHost = (hostent*)gethostbyname("www.google.com"); > > char* pIPAddr = inet_ntoa(*(reinterpret_cast<in_addr*>(pHost- > >h_addr))) ; > > > > > SSL_load_error_strings(); > int nRet = SSL_library_init(); > > SSL_load_error_strings(); > SSLeay_add_all_algorithms (); > SSLeay_add_ssl_algorithms (); > > SSL_METHOD *meth = NULL; > SSL_CTX *ssl_ctx = NULL; > meth = SSLv2_client_method(); > ssl_ctx = SSL_CTX_new(meth); > SSL * ssl = NULL; > ssl = SSL_new(ssl_ctx); > > SOCKET sock = socket(AF_INET, SOCK_STREAM, 0); > > struct sockaddr_in gsin; > gsin.sin_family = AF_INET; > gsin.sin_addr.s_addr = inet_addr((const char*)pIPAddr); > gsin.sin_port = htons(443); > > nRet = connect(sock,(SOCKADDR*) &gsin, sizeof(sockaddr)); > DWORD dw = GetLastError(); > > nRet = SSL_set_fd(ssl, sock); > nRet = SSL_connect(ssl); > CURLEncode url_encode; > CString strTData; > > strTData.Format (L"POST https://www.google.com/accounts/ClientLogin > HTTP/1.0\r\nContent-Type: application/x-www-form-urlencoded\r\nContent- > Length: 119\r\n\r\naccountType=%s&Email=%s&Passwd=%s&service=%s&source= > %s\r\n\r\n", url_encode.URLEncode(L"HOSTED_OR_GOOGLE") , > url_encode.URLEncode(L"[EMAIL PROTECTED]") , > url_encode.URLEncode(L"harishiit") , url_encode.URLEncode(L"cl") , > url_encode.URLEncode(L"DoMo-TestDLL-1.0.0.1")); > > char* pData = new char[strTData.GetLength () + 1]; > ::WideCharToMultiByte (CP_ACP , 0 , strTData , strTData.GetLength () , > pData , strTData.GetLength () , NULL , NULL); > pData[strTData.GetLength ()] = '\0'; > > // Making HTTPS POST > nRet = SSL_write(ssl, pData, strlen(pData)); //sending HTTP POST > delete []pData; > > nRet = SSL_state(ssl); > > char buf[1000]; > memset(buf , 0 , sizeof(buf)); > int nret; > CString m_out = L""; > while(nret = SSL_read(ssl, buf, 999)) > { > buf[nret] = 0; > CString str(buf); > m_out += str; > } > > CString strAuthKey = L""; > int nIndex = m_out.Find (L"Auth="); > if(nIndex != -1) > { > strAuthKey = m_out.Mid (nIndex + 5 , m_out.GetLength () - nIndex - > 4); > strAuthKey.Trim (); > } > > strTData = L""; > strTData.Format (L"GET > http://www.google.com/calendar/feeds/%s/private/full > HTTP/1.0\r\n Authorization: GoogleLogin auth=%s \r\n\r\n" , > url_encode.URLEncode(L"[EMAIL PROTECTED]") , strAuthKey ); > > pData = NULL; > pData = new char[strTData.GetLength () + 1]; > ::WideCharToMultiByte (CP_ACP , 0 , strTData , strTData.GetLength () , > pData , strTData.GetLength () , NULL , NULL); > pData[strTData.GetLength ()] = '\0'; > > > // Making HTTPS GET > > nRet = SSL_write(ssl, pData, strlen(pData)); //sending HTTP POST > delete []pData; > > nRet = SSL_state(ssl); > > memset(buf , 0 , sizeof(buf)); > m_out = L""; > > // here in response i m getting blank in place of xml data.... > while(nret = SSL_read(ssl, buf, 999)) > { > buf[nret] = 0; > CString str(buf); > m_out += str; > } > > > WSACleanup( ); > > > I think problem may be in following GET request: > > strTData.Format (L"GET > http://www.google.com/calendar/feeds/%s/private/full > HTTP/1.0\r\n Authorization: GoogleLogin auth=%s \r\n\r\n" , > url_encode.URLEncode(L"[EMAIL PROTECTED]") , strAuthKey ); > > > What wrong i m doing... > Can someone help me > > Harry > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
