Forum Moderators: coopster
<?php
// getToPost.php - converts a GET encoded URL to a POST
// To remove the pain in the **** that testing POST forms are
// Thrown together by TrillianJedi and published on WebmasterWorld.com, 28/03/2010. Public Domain, E&OE....
// Requires cURL library
//
// Edit the "<WHEREVER_YOU_PUT_THIS>" bit to use and upload to a cURL enabled PHP webserver
$uri = $_POST['data'];
if ($uri == "") {
echo "
<html>
<head>
<title>Post Me</title>
</head>
<body>
<div style='text-align:center; padding: 50px;'>
<form action='http://<WHEREVER_YOU_PUT_THIS>/getToPost.php' method='post'>
URL : <input type='text' name='data' style='width: 550px'>
<INPUT type='submit' value='Post It For Me'>
<form>
</div>
</body>
</html>
";
} else {
// Do the post
// Get the POST url
$postArray = explode("?", $uri);
$url = $postArray[0];
$args = $postArray[1];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
// If this takes longer than 5 seconds, we probably have an issue....
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,5);
$posted = curl_exec($ch);
curl_close($ch);
// Quick and dirty output check - if this is XML like a lot of XML-RPC webservices are, make it render nicely in browser
if (strstr($posted, "<?xml")) {
header ("content-type: text/xml");
}
echo $posted;
}
?>