在MFC中連接https
//Header
CString strHeaders =
_T("Content-Type: application/x-www-form-urlencoded");
// URL-encoded form variables -
// name = "John Doe", userid = "hithere", other = "P&Q"
CString strFormData = _T("Email=&Passwd=&service=youtube&source=Test "); // connect to youtube
INTERNET_PORT nPort = INTERNET_DEFAULT_HTTPS_PORT;
CInternetSession session;
CHttpConnection* pConnection =
session.GetHttpConnection(_T("www.google.com"),nPort);
//下面這段很重要
CHttpFile* pFile =
pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,
_T("/youtube/accounts/ClientLogin"),NULL,1,NULL,NULL,
INTERNET_FLAG_EXISTING_CONNECT|
INTERNET_FLAG_SECURE|
INTERNET_FLAG_IGNORE_CERT_CN_INVALID|
INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
);
//Send Request
BOOL result = pFile->SendRequest(strHeaders,
(LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
//Get Response
pFile->ReadString(strGetData);