View Full Version : HTTP request using GET method
manju
04-17-2002, 04:29 AM
HI,
I want to send data entered in BREW enabled mobile handset using HTTP GET method.
I want to go to url: http://abc.com?val1=10&val2=20"
val1 and val2 are the values I get form Brew phone.
val1 I sin pme->m_val1 and val2 is in pme->val2.
how do I pass these 2 values through the url.
When I hardcode the values I get my result.
Thanks
Hi
U can use STR_TO_WSTR to print the format in a AECHAR buffer pme->m_szFormat and then use WSPRINTF to print values in the buffer as shown below,
STR_TO_WSTR("GET /abc.com?val1=%d&val2=%d HTTP/1.0 \n\n", pme->m_szFormat, sizeof(pme->m_szFormat));
WSPRINTF(pme->m_SendBuf, sizeof(pme->m_SendBuf), pme->m_szFormat, pme->m_val1,pme->m_val2);
After these statements u will have ( example values 10 , 20)
"GET /abc.com?val1=10&val2=20 HTTP/1.0 \n\n" in the pme->m_SendBuf variable.
Try it . It will work
Best of Luck :-)
raja
__________________
Thanks
Manju
manju
04-18-2002, 12:21 AM
Hi,
Nope it gives me an error:( I shall write where am stuck:
this is what my code looks now Right now am sending using %s for only one input username------
STR_TO_WSTR("http://manju/oms/Brewappsub.asp?txtUserName=%s&txtBarCode=9780000000798&txtQuantity=1 HTTP/1.0\r\n\r\n",pme->m_szFormat, sizeof(pme->m_szFormat));
WSPRINTF(pme->m_SendBuf, sizeof(pme->m_SendBuf), pme->m_szFormat, pme->m_Name);
sprintf(Request, "GET %s", pme->m_SendBuf );
iRet = ISOCKET_Write(pme->m_piSock, (byte*)Request, (uint16)STRLEN(Request));
ByteCount = ISOCKET_Read(piSock, (byte*)buf, sizeof(buf));
the BYTECOUNT = AEE_NET_WOULDBLOCK so in OmsApp-ReadCB it goes into an infinite loop as it cannot read on socket.
when i ckeck the value stored in pme->m_SendBuf it contains only "Get h" rest is null. when i check value in pme->m_szFormat it contains only 'h'. all my varaibles in pme are AECHAR.
what is the way out :confused: Any help would be appreciated.
Hi
Hey, Check the allocation for all the variables tat u r using for setting up this. Instead of sprintf , try using the API WSR_TO_UTF8 () conversion function. And try to watch the variables in QuickWatch.
raja.
manju
04-21-2002, 10:53 PM
Hi,
I still face the same error. I have variables pme->username and pme->Barcode defined as AECHAR in my structure definition.
I have values "Manju" and "007894561" stored in the variables theu screens respectively.
I write
sprintf(Request, "GET HTTP://manju/oms/Brewappsub.asp?txtUserName=%s&txtBarCode=%s&txtQuantity=1 HTTP/1.0\r\n\r\n",pme->m_Name ,pme->m_barcode);
when i do a quick watch pme->m_Name has manju stored
m_barcode has 007894561
but request has GET HTTP://manju/oms/Brewappsub.asp?txtUserName=m&txtBarCode=0&txtQuantity=1 HTTP/1.0\r\n\r\n
the first chracters of pme->m_Name and pme->m_barcode (m and 0) are only taken into the url..
any idea why its happening so :confused:
Any help will be appreciated.
vBulletin v3.0.13, Copyright ©2000-2009, Jelsoft Enterprises Ltd.