Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

curl postfields ( adaptation of php script)

by haricot (Initiate)
on Feb 28, 2017 at 17:18 UTC ( [id://1183173]=perlquestion: print w/replies, xml ) Need Help??

haricot has asked for the wisdom of the Perl Monks concerning the following question:

Hello , i want/need to convert this code(in php) to perl's code but i am very stunk on the CURLOPT_POSTFIELDS part . i'm not able to convert this to perl .. could somebody helps me ?
$curl = curl_init($apiUrl); $curlPostData = array( "force_post" => urlencode("true"), "auth_hash" => $authHash, "urlencoded_filename" => urlencode($fileName), "auth_token" => $authToken, "xhr_uploader" => urlencode("true"), 'userfile_0"; filename="fake-name"' => $fileDa +ta ); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: mu +ltipart/form-data")); curl_setopt($curl, CURLOPT_USERPWD, $pydioRestUser . ":" . $py +dioRestPw); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPostData); $response = curl_exec($curl);

Replies are listed 'Best First'.
Re: curl postfields ( adaptation of php script)
by 1nickt (Canon) on Feb 28, 2017 at 17:30 UTC

    Hi haricot,

    Please use <code></code> tags for your code as described in Writeup Formatting Tips.

    For your question, see HTTP::Tiny ( post_form() ) or perhaps Net::CURL (I have not used the latter but it comes recommended by the highest papal authorities).

    Hope this helps!


    The way forward always starts with a minimal test.
Re: curl postfields ( adaptation of php script)
by Cow1337killr (Monk) on Mar 01, 2017 at 18:02 UTC

    It appears that you are new to PerlMonks, but I (and we) have no idea how comfortable you are with reading and writing Perl code.

    Based on your question, we can only guess at what it is that you are trying to do.

    Rather than convert a php solution to what you are trying to do, please explain to us what it is that you are trying to do, and you will probably see close to half a dozen responses on how to accomplish your task.

    By the way, I tried the following Google search: perl "curl_exec" - Google Search.

    I was surprised at the number of questions in the search results that were similar to yours.

    This one was at the top of the list (for me): Code from PHP to Perl.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1183173]
Approved by 1nickt
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-25 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found