#1
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?
Topic Starter
  • vcsharp
  • Rank: YAF Commander
  • Reputation:
    Honored
    85.4%
  • Joined: 03/10/2017
  • Posts: 76
  •  Man  India
  • Thanks: 24 times
  • Was thanked: 1 time(s) in 1 post(s)
#2
You only need to enable it in the host settings, and enter the api key!
UserPostedImage
  • tha_watcha
  • Rank: YAF.NET Project Lead
  • Reputation:
    Exalted
    100%
  • Medals:
    Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.
  • Joined: 06/03/2010
  • Posts: 4,003
  •  Germany
  • Thanks: 74 times
  • Was thanked: 1207 time(s) in 1032 post(s)
#3
Thanks.

A related question: Will this api key host setting work on localhost, or it only works in a real live hosted scenario?
  • Sunil Dhaul
  • Rank: YAF Forumling
  • Reputation:
    Neutral
    50.8%
  • Joined: 24/03/2018
  • Posts: 1
  •  Man 
#4
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
  • tha_watcha
  • Rank: YAF.NET Project Lead
  • Reputation:
    Exalted
    100%
  • Medals:
    Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.
  • Joined: 06/03/2010
  • Posts: 4,003
  •  Germany
  • Thanks: 74 times
  • Was thanked: 1207 time(s) in 1032 post(s)
#5
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.

Topic Starter
  • vcsharp
  • Rank: YAF Commander
  • Reputation:
    Honored
    85.4%
  • Joined: 03/10/2017
  • Posts: 76
  •  Man  India
  • Thanks: 24 times
  • Was thanked: 1 time(s) in 1 post(s)
#6
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
  • tha_watcha
  • Rank: YAF.NET Project Lead
  • Reputation:
    Exalted
    100%
  • Medals:
    Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.
  • Joined: 06/03/2010
  • Posts: 4,003
  •  Germany
  • Thanks: 74 times
  • Was thanked: 1207 time(s) in 1032 post(s)
#7
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.

Topic Starter
  • vcsharp
  • Rank: YAF Commander
  • Reputation:
    Honored
    85.4%
  • Joined: 03/10/2017
  • Posts: 76
  •  Man  India
  • Thanks: 24 times
  • Was thanked: 1 time(s) in 1 post(s)
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