 |
|
 |
You must call GetHeaders(url) before GetPageStatusCode(). If not, the "Headers" variable is empty and GetPageStatusCode() depend on it.
But take care, GetHeaders use InternetOpenUrl(...) with NO header, so the server can reject the request.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I'm finding some issues...
First, if I use like this :
char *s = http.GetPage(_T("http://somewebpage/", true, "?Username=SomeUser&Password=SomePassword&Otherdata=SomeMoreData");
I can't compile : ---------------------- --------------------Configuration: ValidaLogin - Win32 Debug-------------------- Compiling... ValidaLoginDlg.cpp C:\Arquivos de programas\Microsoft Visual Studio\MyProjects\ValidaLogin\ValidaLoginDlg.cpp(184) : warning C4002: too many actual parameters for macro '_T' C:\Arquivos de programas\Microsoft Visual Studio\MyProjects\ValidaLogin\ValidaLoginDlg.cpp(184) : error C2143: syntax error : missing ')' before ';' Error executing cl.exe.
ValidaLogin.exe - 1 error(s), 1 warning(s) -----------------
And if I use like this
char *s = http.GetPage(_T("http://192.168.0.16:8080/email/TmidiaServlet", true, "?user=Felipe?user=Felipe&pass=123"));
It works half way. I can access the server, but it receives NULL parameters... both 'user' and 'pass' , the server receives NULL.
Do you have any idea ???
Please, I need this SAP.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
try this:
char *s = http.GetPage(_T("http://somewebpage/"), true, "?Username=SomeUser&Password=SomePassword&Otherdata=SomeMoreData");
you missed a ')'
bye
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hello, I would like to send some data to a server (my login data) and get data out of the users area afterwards.
CAmHttpSocket http; http.GetPage(_T("http://my.onvista.de/login.html"), true, "my login data"); http.GetPage(_T("http://my.onvista.de/login.html")); char *s = http.GetPage(_T("http://my.onvista.de/mymarket/index.html"));
int i = http.GetPageStatusCode();
This didn't work. Does the class manage cookies? If not, what can I do?
Thanks, Michael
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I tried using this code on a button press.. [code] CAmHttpSocket http; char *s = http.GetPage(_T("http://192.168.1.209/adeeltest/default.aspx[^]"), true, "?name=Adeel&Addy=Miami&Contact=343435454&mail=sanjeev@sampatti.com&address=florida&Comments=misc"); [/code]
but unfortunately its posting the data at all (I checked in the Database the table is blank). Can anyone please help me??
-- modified at 8:36 Monday 7th August, 2006
|
| Sign In·View Thread·PermaLink | 1.40/5 (2 votes) |
|
|
|
 |
|
 |
help me,i can't set proxy. bool CAmHttpSocket::OpenUrl(const TCHAR *url) { if (hIS != NULL) InternetCloseHandle(hIS); hIS = InternetOpenUrl(hIO, url, NULL, 0, HTTP_QUERY_DATE, 0); if (hIS != NULL) return true; else { LastError = GetLastError(); return false; } } thank you
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Is it possible with this Class to post a XML File to the Server and recieve the answer?
If it is: how? If not: does anybody know how to do it(Link to sample code)?
And another Problem: unresolved external Symbol '__imp__InternetOpenA@20'
What library do I have to link to?
Thank you...
-- modified at 5:31 Thursday 6th April, 2006
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
Hey, i was testing your class to make some https requests but didn't work directly cause my server certificate isn't verified... GetLastError() is returning the 12045 error ( ERROR_INTERNET_INVALID_CA )
I found solution in msdn to handle that kind of problem: article number 182888: http://support.microsoft.com/kb/q182888/
bool CAmHttpSocket::PostUrl(const TCHAR *url, const char *PostData, int PostDataLength) { if (PostDataLength == -1) PostDataLength = strlen(PostData); URL_COMPONENTS uc; uc.dwStructSize = sizeof(uc); uc.lpszScheme = NULL; uc.dwSchemeLength = 0; uc.lpszHostName = NULL; uc.dwHostNameLength = 1; uc.nPort = 0; uc.lpszUserName = NULL; uc.dwUserNameLength = 0; uc.lpszPassword = NULL; uc.dwPasswordLength = 0; uc.lpszUrlPath = NULL; uc.dwUrlPathLength = 1; uc.lpszExtraInfo = NULL; uc.dwExtraInfoLength = 0; InternetCrackUrl(url, _tcslen(url), 0, &uc); if (hCO != NULL) InternetCloseHandle(hCO); TCHAR *HostName = _tcsdup(uc.lpszHostName); HostName[uc.dwHostNameLength] = '\0'; TCHAR *FileName = _tcsdup(uc.lpszUrlPath); FileName[uc.dwUrlPathLength] = '\0'; if (hIS != NULL) InternetCloseHandle(hIS); DWORD flags; if (uc.nPort == 80) { flags = INTERNET_FLAG_NO_CACHE_WRITE; } else { flags = INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_SECURE | INTERNET_FLAG_IGNORE_CERT_CN_INVALID | INTERNET_FLAG_IGNORE_CERT_DATE_INVALID ; } TCHAR headers[] = _T("Content-Type: application/x-www-form-urlencoded"); TCHAR szAccept[] = _T("*/*"); LPTSTR AcceptTypes[2]={0}; AcceptTypes[0]=szAccept; hCO = InternetConnect(hIO, HostName, uc.nPort, _T(""), _T(""), INTERNET_SERVICE_HTTP, INTERNET_FLAG_NO_CACHE_WRITE, 0); hIS = HttpOpenRequest(hCO, _T("POST"), FileName, NULL, NULL, (LPCTSTR*)AcceptTypes, flags, 0); again: if (!HttpSendRequest(hIS, headers, _tcslen(headers), (TCHAR*)PostData, PostDataLength)) { LastError = GetLastError(); if(LastError == ERROR_INTERNET_INVALID_CA) { DWORD dwFlags; DWORD dwBuffLen = sizeof(dwFlags);
InternetQueryOption (hIS, INTERNET_OPTION_SECURITY_FLAGS, (LPVOID)&dwFlags, &dwBuffLen);
dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA; InternetSetOption (hIS, INTERNET_OPTION_SECURITY_FLAGS, &dwFlags, sizeof (dwFlags) ); goto again;
} free(HostName); free(FileName); return false; } free(HostName); free(FileName); return true; }
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
This may be a false alarm but visual studio indicates a memory leak in function CAmHttpSocket::GetPage at this line ReceivedData = (char*)realloc(ReceivedData, curpos + rdsize);
|
| Sign In·View Thread·PermaLink | 2.50/5 (3 votes) |
|
|
|
 |
|
|
 |
|
 |
I included this files to my program and I have error like:
Linking... AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__InternetOpenA@20 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__InternetCloseHandle@4 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__InternetOpenUrlA@24 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__HttpSendRequestA@20 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__HttpOpenRequestA@32 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__InternetConnectA@32 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__InternetCrackUrlA@16 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__HttpQueryInfoA@20 AmHttpSocket.obj : error LNK2001: unresolved external symbol __imp__InternetReadFile@16 Debug/postdata.exe : fatal error LNK1120: 9 unresolved externals Error executing link.exe.
What that error means? How can I remove this error? It will be fine if you help me 
Sorry for my English Bye
|
| Sign In·View Thread·PermaLink | 1.75/5 (4 votes) |
|
|
|
 |
|
 |
[code]#pragma comment(lib, "wininet.lib")
#pragma once
#include #include #include [/code]
Should help (on MSVS)
|
| Sign In·View Thread·PermaLink | 4.00/5 (1 vote) |
|
|
|
 |
|
 |
D:\C\ALLEGRO\WWW/amhttpsocket.h(14) : error C2061: syntax error : identifier 'CAmHttpSocket' D:\C\ALLEGRO\WWW/amhttpsocket.h(14) : error C2059: syntax error : ';' D:\C\ALLEGRO\WWW/amhttpsocket.h(14) : error C2449: found '{' at file scope (missing function header?) D:\C\ALLEGRO\WWW/amhttpsocket.h(29) : error C2059: syntax error : '}'
It looks like there is something wrong with the class ?
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
hello
i want to get the web page and save it to the location i specify without viewing it how can it be done what functions will be used in this application.
du_aa
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
Hi... Very Nice code u've written..Thanks.. But I don't find yet How to Upload file... if u discover this..also...then Plz update this Class... I'm waiting.... Thanks Again for such a nice code..
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
I am looking forward to uploading feature too...
Seems this class can only post a NULL terminated string, cannot post a buffer content.
Maybe someone experts can expand this class....
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Nice to see reply after about 5 years...
At that time, even I fixed that issue. But now it's too long to even remember what exactly I did at that time.
Anyway, Thanks for reply(I can understand, how hard is to get free time. Even I hardly get).
Regards, Sumit K. sumit_kapoor1980@yahoo.com
Never consider anything impossible before trying to solve that..---Sumit Kapoor---
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Just wondering how you would go about, getting it to call a *.gif(online) if it was online, and vise versa if it was offline.
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |