Welcome Guest! To enable all features please Login or Register.
Options
View
Go to last post Go to first unread
Offline vcsharp  
#1 Posted : 04 April 2018 16:41:37(UTC)
vcsharp


Rank: YAF Lover

Reputation:

Joined: 03/10/2017(UTC)
Posts: 59
Man
India

Thanks: 21 times
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?


Code:
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?

Edited by user 06 April 2018 07:21:45(UTC)  | Reason: missing something in code

Sponsor
Offline tha_watcha  
#2 Posted : 04 April 2018 18:21:32(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

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(UTC)
Posts: 3,893
Germany

Thanks: 73 times
Was thanked: 1183 time(s) in 1013 post(s)
You only need to enable it in the host settings, and enter the api key!
thanks 1 user thanked tha_watcha for this useful post.
vcsharp on 04/04/2018(UTC)
Offline Sunil Dhaul  
#3 Posted : 04 April 2018 20:23:15(UTC)
Sunil Dhaul


Rank: YAF Forumling

Reputation:

Joined: 24/03/2018(UTC)
Posts: 1
Man

Thanks.

A related question: Will this api key host setting work on localhost, or it only works in a real live hosted scenario?
Offline tha_watcha  
#4 Posted : 05 April 2018 20:37:45(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

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(UTC)
Posts: 3,893
Germany

Thanks: 73 times
Was thanked: 1183 time(s) in 1013 post(s)
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

Edited by user 05 April 2018 22:52:27(UTC)  | Reason: Not specified

thanks 1 user thanked tha_watcha for this useful post.
vcsharp on 06/04/2018(UTC)
Offline vcsharp  
#5 Posted : 06 April 2018 06:46:24(UTC)
vcsharp


Rank: YAF Lover

Reputation:

Joined: 03/10/2017(UTC)
Posts: 59
Man
India

Thanks: 21 times
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.

Offline tha_watcha  
#6 Posted : 06 April 2018 17:11:30(UTC)
tha_watcha


Rank: YAF.NET Project Lead

Reputation:

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(UTC)
Posts: 3,893
Germany

Thanks: 73 times
Was thanked: 1183 time(s) in 1013 post(s)
Originally Posted by: vcsharp Go to Quoted Post
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
thanks 1 user thanked tha_watcha for this useful post.
vcsharp on 08/04/2018(UTC)
Offline vcsharp  
#7 Posted : 08 April 2018 08:19:05(UTC)
vcsharp


Rank: YAF Lover

Reputation:

Joined: 03/10/2017(UTC)
Posts: 59
Man
India

Thanks: 21 times
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.

Rss Feed  Atom Feed
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.

Notification

Icon
Error