AkismetApi.Net
2.0.0
Install-Package AkismetApi.Net -Version 2.0.0
dotnet add package AkismetApi.Net --version 2.0.0
<PackageReference Include="AkismetApi.Net" Version="2.0.0" />
paket add AkismetApi.Net --version 2.0.0
#r "nuget: AkismetApi.Net, 2.0.0"
// Install AkismetApi.Net as a Cake Addin
#addin nuget:?package=AkismetApi.Net&version=2.0.0
// Install AkismetApi.Net as a Cake Tool
#tool nuget:?package=AkismetApi.Net&version=2.0.0
Akismet.Net
Complete and full-featured Akismet client for .NET
Existing libraries don't allow for all of the possible options available in the Akismet API and the source code is not public. This library is meant to fix that.
It is also multi-targeted to support as many applications as possible.
Meant to be a drop-in replacement for the leading Akismet library with minimal changes so the class names are the same. However some properties have been removed because of redundancy.
Example usage:
var model = new ContactModel();
string ip = Request.Headers["CF-Connecting-IP"] ?? Request.UserHostAddress;
if (String.IsNullOrWhiteSpace(ip))
ip = Request.ServerVariables["REMOTE_HOST"];
AkismetClient akismet = new AkismetClient("apikeyhere", new Uri("https://www.adamh.us"), "Application Name");
AkismetComment comment = new AkismetComment
{
CommentAuthor = model.Name,
CommentAuthorEmail = model.EmailAddress,
CommentAuthorUrl = "http://www.spamwebsite.com",
Referrer = Request.UrlReferrer.ToString(),
UserAgent = Request.UserAgent,
UserIp = ip,
CommentContent = model.Message,
CommentType = AkismentCommentType.ContactForm, // multiple defined values, or use new AkismetCommentType("new-comment-type") for a custom option
Permalink = "https://www.adamh.us/contact",
IsTest = "false",
BlogCharset = "UTF-8",
BlogLanguage = "en-US",
CommentDate = DateTime.UtcNow.ToString("s"), // ISO-8601 format
CommentPostModified = DateTime.UtcNow.ToString("s"), // ISO-8601 format
UserRole = "administrator",
RecheckReason = "edit",
HoneypotFieldName = "honeypot",
HoneypotFieldValue = "blah"
};
var akismetResult = akismet.Check(comment);
bool isSpam = akismetResult.SpamStatus == SpamStatus.Spam; // Options: Ham, Spam, Unspecified (in the case of an error)
// "invalid" and/or combination of X-akismet-alert-code and X-akismet-alert-msg header values
foreach (string err in akismetResult.Errors)
Console.WriteLine(err);
// Other properties:
// - ProTip (X-akismet-pro-tip header value, if present)
// - DebugHelp (X-akismet-debug-help header value, if present)
If HoneypotFieldName
and HoneypotFieldValue
are supplied then the library will add these two values to the request:
honeypot_field_name=honeypot&honeypot=blah
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net452 net46 net461 net462 net463 net47 net471 net472 net48 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETCoreApp 3.1
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 106.13.0)
-
.NETFramework 4.5.2
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 106.13.0)
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 106.13.0)
-
net5.0
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 106.13.0)
-
net6.0
- Newtonsoft.Json (>= 13.0.1)
- RestSharp (>= 106.13.0)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on AkismetApi.Net:
Package | Downloads |
---|---|
Akismet.Umbraco8.Core
Akismet for Umbraco 8 |
|
Akismet.UmbracoForms8.Workflow
Akismet Workflow for Umbraco Forms 8 |
|
Akismet.Umbraco
Akismet for Umbraco (9+) |
GitHub repositories
This package is not used by any popular GitHub repositories.
Dropped support for .NET Core 2.1 and added support for .NET 6