forked from DNNCommunity/DNN.FormAndList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReCaptcha.cs
25 lines (22 loc) · 854 Bytes
/
ReCaptcha.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;
namespace DotNetNuke.Modules.UserDefinedTable.Components
{
public class ReCaptcha
{
public static bool Validate(string encodedResponse, string privateKey)
{
var client = new System.Net.WebClient();
var googleReply = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", privateKey, encodedResponse));
var captchaResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<ReCaptcha>(googleReply);
return captchaResponse.Success;
}
[JsonProperty("success")]
public bool Success { get; set; }
[JsonProperty("error-codes")]
public List<string> ErrorCodes { get; set; }
}
}