Forum Moderators: coopster & phranque

Message Too Old, No Replies

Cross posting to other web sites

Posting data automatically to forms on other websites

         

techiejp

1:21 pm on Oct 25, 2001 (gmt 0)



Our company is in need of posting information we get to other web sites as a value added service. (I can't give out too much more information, but it's completely legit, not a scheme). At any rate, we are very big on Coldfusion here. Coldfusion is however really not the best language to use for something like this. CFHTTP is weak on Coldfusion. Could someone who's done something like this recommend scripting languages, or programs that could make this very simple, and 100% automated? Thanks in advance.

sugarkane

5:51 pm on Oct 25, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could do this in Perl using the LWP and HTTP modules - eg:

[perl]
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;
$ua = new LWP::UserAgent;

my $req = POST 'http://www.somesite.com/cgi-bin/form.cgi',
[ field1 => 'value1', field2 => 'value2' ];

print $ua->request($req)->as_string;
[/perl]

techiejp

6:15 pm on Oct 25, 2001 (gmt 0)



Thanks sugarkane. Could you explain, if possible, how you deal with sites that might set cookies so you can post to multiple pages in succession or how you might deal with error responses?

Thanks again.

sugarkane

6:28 pm on Oct 25, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, errors are simple enough to cope with

[perl]
my $response = $ua->request($req);
if ($response->is_error()) { print "Error!"; }
else {
# Everything's ok, do stuff here
}
[/perl]

The cookie stuff is a bit more complicated - if you envisage running into problems with them, would it not be an idea to turn things on their head? Publish info on your own site, and have the remote sites pull the info with a simple bit of PHP (or whatever) code?