How i can run this commando curl:
curl -F "param01=value01" -F "param02=value02" -v http://example.com/Home/Login
Using PHP ?
Doubt is because the parameter -F, I never used it...
UPDATE:
curl man page:
-F, --form
(HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.
You'll use the POST example, at the bottom of my response.
If param01 and param02 are GET/url parameters, this will work.
<?php
// Setup our curl handler
if (!$ch = curl_init())
{
die("cURL package not installed in PHP");
}
$value1 = urlencode("something");
$value2 = urlencode("something");
curl_setopt($ch, CURLOPT_URL,'http://example.com/Home/Login?param01='.$value1.'¶m02='.$value2);
curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); // TRUE if we want to track the request string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // TRUE to return the transfer as a string
$response = curl_exec($ch);
if(curl_error($ch) != "")
{
die("Error with cURL installation: " . curl_error($ch));
}
else
{
// Do something with the response
echo $response;
}
curl_close($ch);
If they are POST (form data):
<?php
// Setup our curl handler
if (!$ch = curl_init())
{
die("cURL package not installed in PHP");
}
$value1 = urlencode("something");
$value2 = urlencode("something");
$data = array(
'param1' => $value1,
'param1' => $value2,
)
curl_setopt($ch, CURLOPT_URL,'http://example.com/Home/Login');
curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE); // TRUE if we want to track the request string
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // TRUE to return the transfer as a string
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
if(curl_error($ch) != "")
{
die("Error with cURL installation: " . curl_error($ch));
}
else
{
// Do something with the response
echo $response;
}
curl_close($ch);
Everything you need and more:
simple example:
$ch = curl_init();
$curlConfig = array(
CURLOPT_URL => "http://www.example.com/yourscript.php",
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => array(
'field1' => 'some date',
'field2' => 'some other data',
),
);
curl_setopt_array($ch, $curlConfig)
$result = curl_exec($ch);
curl_close($ch);