The problem is that it works *sometimes*. This I do not understand. Why does it work sometimes? Is it my script or is it Typepad? Here is the script below. Sometimes the post does not go through but I still get a status of '200' back from Typepad. Alternatively, anyone know any API's or other methods for posting a comment on Typepad? I've looked at their APIs and they do not have anything that will post a comment....the APIs are only able to add a blog post.
#!/usr/local/bin/perl require "../cgi-lib.pl"; print "Content-type: text/html\n\n"; &ReadParse(*F); my $error = ''; $author = $F{'author'}; # username of the person posting $email = $F{'email'}; # users email address $comment = $F{'comment'}; # comment to submit $comment =~ s/\%([A-Fa-f0-9]{2})/pack('C', hex($1))/seg;; $url = $F{'url'}; # the url of the blog post $url =~ s/\/comments\/atom.*/\.html/; chomp($url); if ($author eq '') { $author = 'Anonymous'; } if ($email eq '' ) { $error .= 'Email was blank. Comment not posted'; +} if ($comment eq '' ) { $error .= 'Error: Comment was blank.'; } if ($error ne '' ) { print $error; exit; } use LWP::Simple; use WWW::Mechanize; use HTTP::Cookies; my $m = WWW::Mechanize->new( autocheck=>1); $m->get($url); print $m->response->status_line; if ($m->success) { $m->form('comment-form'); $m->field('author',$author); $m->field('email',$email); $m->field('url',''); $m->field('text',$comment); $m->click('post'); print "Your comment has been posted."; print $m->response->status_line; } else { print "Was not able to connect to website."; }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |