PDA

Просмотр полной версии : Posting forms with CHtmlView



Anonymous
26.03.2004, 19:52
Подскажите, кто знает, как програмно заполнять и отсылать формы?

maxrus
19.06.2004, 13:46
Вот эта функция у меня отсылала на хост данные
типа такого содержания
//////////////////////////////////////////////////////
POST /index_.php?f=smssend_result.htm HTTP/1.1
Content-Type: application/x-www-form-urlencoded
ContentLength: 24

Num2=79058949461&Msg2=OK
///////////////////////////////////////////

void CSmsDlg::OnOK()
{
CInternetSession session;
CHttpConnection* pConnection;
CHttpFile* pFile;
TRY
{
//decode " "(32) to "+"(43)
this->UpdateData();
CString strHeaders=
_T("Content-Type: application/x-www-form-urlencoded");
CString msg=m_msg;
for (int i=0;i<m_msg.GetLength();i++)
if (m_msg[i]==' ')
msg.SetAt(i,TCHAR('+'));
CString strFormData = _T("Num2=")+m_number+_T("&Msg2=")+msg;
////////////////////////////
BOOL result;
/////////////////////////////
pConnection=session.GetHttpConnection("sms.orensot.ru");
pFile=pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,
_T("/index_.php?f=smssend_result.htm"));
/////////////////////////////
//MessageBox(strFormData);
/////////////////////////////
for (int j=0;j<m_num_msg;j++)
result = pFile->SendRequest(strHeaders,(LPVOID)(LPCTSTR)strFormDat a, strFormData.GetLength());
/////////////////////////////
MessageBox("Ok!");
/////////////////////////////
pConnection->Close();
pFile->Close();
session.Close();
}
CATCH_ALL(e)
{
TCHAR szCause[255];
e->GetErrorMessage(szCause, 255);
pConnection->Close();
pFile->Close();
session.Close();
MessageBox(szCause,"ERROR!", MB_OK | MB_ICONERROR);
this->SendMessage(WM_CLOSE,0,0);
}
END_CATCH_ALL;
}