cURL / Mailing Lists / curl-library / Single Mail

curl-library

Curl through VB.NET almost working but..

From: Perkins, Christopher J <Christopher.J.Perkins_at_questdiagnostics.com>
Date: Thu, 21 Oct 2010 13:32:09 -0400

I have a program that I use in VBA that utilizes cURL to pull data from a website, and it works fine. I am trying to get this working with VB.NET (more specifically through ASP.NET using VB.NET). I have the VB.NET bindings and I think they are working, but I am totally unclear as to how to view the response back from the website. Below is my function that is supposed to pull data from a specific website so that I can parse it, again all these options are set in the VBA application and it works perfectly. I think the areas I'm having trouble with are the CURLOPT_WRITEFUNCTION and the CURLOPT_WRITEDATA. I have absolutely no idea where the response text goes, but I can see that I'm getting over 14000 bytes so I know that it exists somewhere. In VBA the data was put to a place called buffer.stringData, but this is not the case in VB.NET. Any help would be much appreciated. Thank you, Chris Public Function CurlTest(ByVal url As String, ByVal recipID As String, ByVal RecipDOB As String, ByVal RecipDOI As String, ByVal RecipDOS As String) Try Curl.GlobalInit(CURLinitFlag.CURL_GLOBAL_ALL) Dim MySU As HttpServerUtility Dim buf As New Buffer Dim fp As StreamWriter fp = New StreamWriter("c:\databases\test.txt") Dim tempStr As String = "" MySU = Server Dim easy As Easy easy = New Easy ' Set up write delegate Dim wf As Easy.WriteFunction wf = New Easy.WriteFunction(AddressOf OnWriteData) wf. ' and the SSL delegate Dim sf As Easy.SSLContextFunction sf = New Easy.SSLContextFunction(AddressOf OnSSLContext) Dim pf As Easy.ProgressFunction pf = New Easy.ProgressFunction(AddressOf OnProgress) ' and the rest of the cURL options easy.SetOpt(CURLoption.CURLOPT_TIMEOUT, 30) easy.SetOpt(CURLoption.CURLOPT_SSL_VERIFYPEER, False) easy.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, True) easy.SetOpt(CURLoption.CURLOPT_VERBOSE, True) easy.SetOpt(CURLoption.CURLOPT_PROXY, "111.11.111.111:1111") 'ENTER PROXY IP / PORT easy.SetOpt(CURLoption.CURLOPT_POST, True) easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS, "RecipID=" & recipID & "&RecipDOB=" & RecipDOB & "&RecipDOI=" & RecipDOI & "&RecipDOS=" & RecipDOS & "&Submit=SUBMIT&UserID=UN&UserPW=PW") easy.SetOpt(CURLoption.CURLOPT_COOKIE, "UserID=UN; UserPW=PW; LastTime=" & MySU.UrlEncode(CStr(Today() & " " & Now)) & "; OwnerNum=01") easy.SetOpt(CURLoption.CURLOPT_URL, url) easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf) easy.SetOpt(CURLoption.CURLOPT_WRITEDATA, fp) easy.SetOpt(CURLoption.CURLOPT_NOPROGRESS, 0) easy.SetOpt(CURLoption.CURLOPT_PROGRESSFUNCTION, pf) 'easy.SetOpt(CURLoption.CURLOPT_SSL_CTX_FUNCTION, sf) 'easy.SetOpt(CURLoption.CURLOPT_CAINFO, "ca-bundle.crt") easy.SetOpt(CURLoption.CURLOPT_WRITEINFO, tempStr) easy.Perform() easy.Cleanup() MsgBox(buf.stringData) MsgBox(tempStr) fp.Close() Curl.GlobalCleanup() Catch ex As Exception Console.WriteLine(ex) End Try End Function ------------------------------------------ The contents of this message, together with any attachments, are intended only for the use of the person(s) to which they are addressed and may contain confidential and/or privileged information. Further, any medical information herein is confidential and protected by law. It is unlawful for unauthorized persons to use, review, copy, disclose, or disseminate confidential medical information. If you are not the intended recipient, immediately advise the sender and delete this message and any attachments. Any distribution, or copying of this message, or any attachment, is prohibited.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-10-21