Post to a server with a spam filter

13 views
Skip to first unread message

Dale

unread,
Nov 3, 2010, 12:31:40 PM11/3/10
to ASIHTTPRequest
In an iPhone app I am posting to a server with a spam filter with the
code below and getting rejected. Apparently the spam filter sends a
cookie to authenticate that the sender is not a 'machine'. Is there
an approach to accept and acknowledge receipt of that cookie?

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:
[NSURL URLWithString:@"http://christianscience.com/lectures/wp-
comments-post.php"]];
[request setPostValue:namstr forKey:@"author"]; //comment_from.text
[request setPostValue:commentstr forKey:@"comment"];
[request setPostValue:@"Submit Comment" forKey:@"submit"];
[request setPostValue:[NSString
stringWithFormat:@"%d",comment_post_ID] forKey:@"comment_post_ID"];
[request setTimeOutSeconds:10];
[request setDelegate:self];
[request setDidFailSelector:@selector(uploadFailed:)];
[request setDidFinishSelector:@selector(uploadFinished:)];
[request startAsynchronous];

Return message for the post:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Ticket #11289, IE bug fix: always pad the error page with enough
characters such that it is greater than 512 bytes, even after gzip
compression
abcdefghijklmnopqrstuvwxyz1234567890aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz11223344556677889900abacbcbdcdcededfefegfgfhghgihihjijikjkjlklkmlmlnmnmononpopoqpqprqrqsrsrtstsubcbcdcdedefefgfabcadefbghicjkldmnoepqrfstugvwxhyz1i234j567k890laabmbccnddeoeffpgghqhiirjjksklltmmnunoovppqwqrrxsstytuuzvvw0wxx1yyz2z113223434455666777889890091abc2def3ghi4jkl5mno6pqr7stu8vwx9yz11aab2bcc3dd4ee5ff6gg7hh8ii9j0jk1kl2lmm3nnoo4p5pq6qrr7ss8tt9uuvv0wwx1x2yyzz13aba4cbcb5dcdc6dedfef8egf9gfh0ghg1ihi2hji3jik4jkj5lkl6kml7mln8mnm9ono
-->
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>WordPress &rsaquo; Error</title>
<link rel="stylesheet" href="http://christianscience.com/lectures/wp-
admin/css/install.css" type="text/css" />
</head>
<body id="error-page">
<p><span style="font-size:12px;"><strong>Your location has been
identified as part of a reported spam network. Comments have been
disabled to prevent spam.</strong><br /><br /></span>
</p></body>
</html>

Ben Copsey

unread,
Nov 7, 2010, 7:52:41 AM11/7/10
to asihttp...@googlegroups.com
Hi Dale

> In an iPhone app I am posting to a server with a spam filter with the
> code below and getting rejected.

> <p><span style="font-size:12px;"><strong>Your location has been


> identified as part of a reported spam network. Comments have been
> disabled to prevent spam.</strong><br /><br /></span>

The error message makes it sound like your IP has actually been blacklisted - if this is the case, there's probably not that much you can do.

On the other hand, perhaps this is just a generic (and misleading) error.

> Apparently the spam filter sends a
> cookie to authenticate that the sender is not a 'machine'. Is there
> an approach to accept and acknowledge receipt of that cookie?

ASIHTTPRequest handles cookies automatically, so if all your server required was that the request re-presented an existing cookie, it ought to work if you've already obtained the cookie from the server via another request. I wouldn't have thought that would offer much protection from spam though.

Does the form you are posting to actually have some other security feature, for example a captcha, or unique ID a hidden field that must be posted back when submitting the form?

Best,

Ben

Dale

unread,
Nov 8, 2010, 2:12:12 PM11/8/10
to ASIHTTPRequest
Wp-spamfree is the name of the plug-in for wordpress. They say they
don't use captcha or other ids.
When I ask my client to turn off the filter the post worked just
fine. Oddly when I type too short of a post like "Test" it returns
with a message "Comment is too short" instead of the error I got
before. Any ideas at all would be helpful. Thanks!

http://www.polepositionmarketing.com/library/wp-spamfree/

--Dale

Ben Copsey

unread,
Nov 9, 2010, 4:19:44 AM11/9/10
to asihttp...@googlegroups.com
Hi Dale

>> Does the form you are posting to actually have some other security feature, for example a captcha, or unique ID a hidden field that must be posted back when submitting the form?

> Wp-spamfree is the name of the plug-in for wordpress. They say they


> don't use captcha or other ids.
> When I ask my client to turn off the filter the post worked just
> fine. Oddly when I type too short of a post like "Test" it returns
> with a message "Comment is too short" instead of the error I got
> before. Any ideas at all would be helpful. Thanks!
>
> http://www.polepositionmarketing.com/library/wp-spamfree/


Ah ok. It sounds like they use a combination of javascript and cookies (http://www.polepositionmarketing.com/library/wp-spamfree/#wpsf_how_it_works)

The JS requirement may make this quite tricky. You could use a hidden UIWebView to load the comment form, which would run the JS, but I'm not certain you'd be able to get access to the cookies set from the webview with ASIHTTPRequest.

You could try doing the whole thing with a hidden UIWebView, filling in the form and submitting it with javascript and stringByEvaluatingJavaScriptFromString, but it's not a very elegant solution.

Aside from disabling this plugin, or coming up with an alternative API your app can use to post comments, I'm not really sure what else to suggest, but perhaps someone else has an idea?

Best

Ben

Reply all
Reply to author
Forward
0 new messages