note 115002 added to ref.curl
| From: | helmizz at yahoo dot com | Date: | Sun, 11 May 2014 10:03:37 +0000 |
| Subject: | note 115002 added to ref.curl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199511@lists.php.net to get a copy of this message | ||
This is sample script to use curl, Just input curl_setopt,
exp :
curlsetop[0] ==> name : CURLOPT_URL ; value : http://amazon.com
curlsetop[1] ==> name : CURLOPT_RETURNTRANSFER ; value : true
curlsetop[2] ==> name : CURLOPT_FOLLOWLOCATION ; value : true
You can add form input.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="">
<meta name="Author" content="Helmi Anwar">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<form method="post" action="">
<table>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50"
name="setopt_name[]"></td>
<td>Value :<input type="text" size="50"
name="setopt_value[]"></td>
</tr>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50"
name="setopt_name[]"></td>
<td>Value :<input type="text" size="50"
name="setopt_value[]"></td>
</tr>
<tr class="rowid_add">
<td>curl_setopt [0]</td>
<td>Name : <input type="text" size="50"
name="setopt_name[]"></td>
<td>Value :<input type="text" size="50"
name="setopt_value[]"></td>
</tr>
<tr>
<td><input type="submit" name="submit_yes"
value="EXECUTE"></td>
</tr>
</table>
</form>
<?php
function curl_test($setopt_content)
{
$ch = curl_init();
curl_setopt_array($ch, $setopt_content);
$result_data = curl_exec($ch);
curl_close($ch);
return $result_data;
}
if($_REQUEST['submit_yes']=="EXECUTE")
{
foreach ($_REQUEST['setopt_name'] as $k => $index_content)
{
$value_content=$_REQUEST['setopt_value'][$k];
$index_content =strtoupper($index_content);
eval('$index_content = '.$index_content.';');
//echo ($index_content);
if($index_content!='')
{
if(strtoupper($value_content)=='TRUE')
{$setopt_content[$index_content]=TRUE;}
elseif(strtoupper($value_content)=='FALSE')
{$setopt_content[$index_content]=FALSE;}
else
{$setopt_content[$index_content]=$value_content;}
}
}
$info=curl_test($setopt_content);
}
?>
<textarea name="result" rows="25" cols="100"><?php echo
htmlspecialchars($info);?></textarea>
</body>
</html>
----
Server IP: 72.52.91.14
Probable Submitter: 36.70.84.108
----
Manual Page -- http://php.net/manual/en/ref.curl.php
Edit -- https://master.php.net/note/edit/115002
Del: integrated -- https://master.php.net/note/delete/115002/integrated
Del: useless -- https://master.php.net/note/delete/115002/useless
Del: bad code -- https://master.php.net/note/delete/115002/bad+code
Del: spam -- https://master.php.net/note/delete/115002/spam
Del: non-english -- https://master.php.net/note/delete/115002/non-english
Del: in docs -- https://master.php.net/note/delete/115002/in+docs
Del: other reasons-- https://master.php.net/note/delete/115002
Reject -- https://master.php.net/note/reject/115002
Search -- https://master.php.net/manage/user-notes.php