[progress Communities] [progress Openedge Abl] Forum Post: Re: .net Equivalent To...

  • Thread starter Thread starter tbergman
  • Start date Start date
Status
Not open for further replies.
T

tbergman

Guest
Here's some code I recently wrote to talk to Google for CAPTCHA verification. It posts using the .Net HttpClient. Hopefully this will be enough to get you started. USING System.Net.Http.*. USING System.Collections.Generic.*. USING Progress.Lang.*. USING Progress.Json.ObjectModel.*. METHOD PUBLIC LOGICAL VerifyCaptcha( INPUT CaptchaResponse AS CHARACTER, INPUT IPAddress AS CHARACTER ): DEFINE VARIABLE Client AS HttpClient. DEFINE VARIABLE Response AS HttpResponseMessage. DEFINE VARIABLE JsonParser AS ObjectModelParser. DEFINE VARIABLE ValuesCollection AS "Dictionary ". JsonParser = NEW ObjectModelParser(). Client = NEW HttpClient(). Client:BaseAddress = NEW System.Uri(" www.google.com/.../siteverify") . ValuesCollection = NEW "Dictionary "(). ValuesCollection:Add("secret","xxxxxxx"). ValuesCollection:Add("response",CaptchaResponse). ValuesCollection:Add("remoteip",IPAddress). Response = Client:PostAsync( "", NEW FormUrlEncodedContent(ValuesCollection)) :Result. CaptchaResponse = Response:Content:ReadAsStringAsync():RESULT. IF CAST(JsonParser:Parse(CaptchaResponse),JsonObject):GetLogical("success") THEN RETURN TRUE. ELSE RETURN FALSE. END METHOD.

Continue reading...
 
Status
Not open for further replies.
Back
Top