Hi All,<br><br>Does anyone have any experience with WWW::Curl:Easy?<br><br>I'm needing to convert some code that currently uses HTTP::Request and LWP::UserAgent into WWW::Curl::Easy code.<br>I've got most of it working, there just one case that is not.<br>
<br>I need to send content along with this particular query.<br>Here is what I need to convert to WWW::Mechanize:<br><br>---------------------- CODE ----------------------<br><br><span style="font-family: courier new,monospace;"> my $req = new HTTP::Request POST => $url;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $req->content_type("text/xml");</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $req->header("Authorization", "Basic ".$self->{'config'}->{'creds_64'});</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $req->header("Cookie", $self->{'config'}{'seller_cookies'});</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $req->header("FileFormat", "TabDelimited");</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $req->header("BatchID", "Y");</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $req->content($content);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> my $response = $self->{'ua'}->request($req);</span><br><br>
---------------------- /CODE ----------------------<br><br>That code works perfectly fine.<br><br>This is what I have so far for WWW::Curl::Easy:<br><br>
---------------------- CODE ----------------------<br><br><span style="font-family: courier new,monospace;"> my @headers = ('Content-Type: text/xml',</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'Authorization: Basic '.$self->{'config'}->{$self->{'locale'}}->{'seller_creds_64'},</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'Cookie: '.$self->{'config'}{'seller_cookies'},</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> 'FileFormat: TabDelimited',</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> 'BatchID: Y'</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> );</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $self->{'curl'} = new WWW::Curl::Easy;</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $self->{'curl'}->setopt(CURLOPT_HEADER,0);</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $self->{'curl'}->setopt(CURLOPT_HTTPHEADER,\@headers);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $self->{'curl'}->setopt(CURLOPT_POST, 1);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> $self->{'curl'}->setopt(CURLOPT_POSTFIELDS, $content);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $self->{'curl'}->setopt(CURLOPT_URL, $url);</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> open (my $response_handle, ">", \$response_body);</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> $self->{'curl'}->setopt(CURLOPT_WRITEDATA,$response_handle);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> my $retcode = $self->{'curl'}->perform;</span><br>
<br>---------------------- /CODE ----------------------<br><br>But I'm getting a message back saying that it's not seeing the added $content properly/at all.<br><br>I'm very new to WWW::Curl::Easy and so could use any help.<br>
As I said before, I have standard page curls working perfectly fine, including ones where I send the extra header information.<br>It's just when I try to send extra $content.<br><br>I think this content might need to be sent as an attachment somehow....<br>
<br>Thanks in advance to anyone who can help me out.<br><br>--Alex<br>