vcsharp
  • Posts: 77
  • Joined: 03/10/2017
I am wanting to use Akismet for spam protection.

For this, I am trying to find some sample C# code in yaf.

So far, I have come up with the following just by looking at classes under the folder YAF.Core/Services/CheckforSpam, but not sure if my code below is correct .


Question: Can someone please provide correct sample code for using Akismet in yaf?


HttpClient httpClient = new HttpClient();

YAF.Core.Services.CheckForSpam.AkismetSpamClient akspClient = 
   new YAF.Core.Services.CheckForSpam.AkismetSpamClient("myKey", "http://www.myedu.com/forums/post", httpClient);


Comment comment = new Comment();
//set comment properties

//get whether comment is a spam
string response = akspClient.SubmitComment(comment, "http://www.myedu.com/forums/post");

//how do I now process response to check if comment was  spam?
Sponsor
tha_watcha
  • Posts: 4068
  • Joined: 06/03/2010
You only need to enable it in the host settings, and enter the api key!
UserPostedImage
Sunil Dhaul
  • Posts: 1
  • Joined: 24/03/2018
Thanks.

A related question: Will this api key host setting work on localhost, or it only works in a real live hosted scenario?
tha_watcha
  • Posts: 4068
  • Joined: 06/03/2010
If I remember correctly the api key is only for one domain, but it will work also on localhost.

But i suggest you should better use the other more effective anti spam options in yaf. Akismet is not really helping. You can read more about the Anti Spam options in the documentation

https://github.com/YAFNE...AF.NET-against-Spam-BOTS 
UserPostedImage
vcsharp
  • Posts: 77
  • Joined: 03/10/2017
Thanks for your reply.

I think it will not work on a localhost since webserver on your local machine is not exposed to the world wide web. The Akismet server needs to be able to see your localhost webserver for it to send back a Http response and its not an easy task nowadays with most ISPs blocking a lot of things to localhost with complex router rules.

tha_watcha
  • Posts: 4068
  • Joined: 06/03/2010
Originally Posted by: vcsharp

Thanks for your reply.

I think it will not work on a localhost since webserver on your local machine is not exposed to the world wide web. The Akismet server needs to be able to see your localhost webserver for it to send back a Http response and its not an easy task nowadays with most ISPs blocking a lot of things to localhost with complex router rules.



No thats not correct. It will work. Yaf send the request to the akismet server, and not appositive. This will work on localhost

UserPostedImage
vcsharp
  • Posts: 77
  • Joined: 03/10/2017
You are right. One can connect to Akismet from localhost since its a simple post request to Akismet that can be made from C# code.

I tried this and I was able to post to Akismet from code-behind.

Users browsing this topic
    Forum Jump  
    • You cannot post new topics in this forum.
    • You cannot reply to topics in this forum.
    • You cannot delete your posts in this forum.
    • You cannot edit your posts in this forum.
    • You cannot create polls in this forum.
    • You cannot vote in polls in this forum.

    About Us

    The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

    Powered by Resharper Donate with PayPal button

    Project Twitter Updates

    Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved