Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwm committed Dec 21, 2024
1 parent b7a5e39 commit b84be0e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ AkismetComment comment = new AkismetComment
HoneypotFieldValue = "blah"
};

var akismetResult = akismet.Check(comment);
var akismetResult = await akismet.CheckAsync(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
Expand All @@ -56,7 +56,20 @@ foreach (string err in akismetResult.Errors)

### .NET Core/.NET 5+ Usage Modifications

#### Program.cs / Startup.cs

```charp
builder.Services.AddAkismet(
configuration.ApiKey,
configuration.AkismetApplicationName,
configuration.BlogUrl);
```

#### Service Class / Controller

```csharp
public class ContactFormController(AkismetClient akismetClient)

string ip = Request.Headers["CF-Connecting-IP"].ToString() ?? _contextAccessor.HttpContext?.Connection.RemoteIpAddress?.ToString() ?? "";
if (String.IsNullOrWhiteSpace(ip))
ip = _contextAccessor.HttpContext?.GetServerVariable("REMOTE_HOST") ?? "";
Expand All @@ -66,6 +79,7 @@ AkismetComment comment = new AkismetComment
UserAgent = Request.Headers[HeaderNames.UserAgent],
Referrer = Request.Headers[HeaderNames.Referer]
};
var akismetResult = await akismetClient.CheckAsync(comment)
```

### Notes
Expand Down

0 comments on commit b84be0e

Please sign in to comment.