-3

I'm new to web programming and trying to make a simple PHP script to send a URL request to my friend's website (Eventually I want to be able to spam it because he has a comments section haha). I tried copying a script from here http://www.php.net/manual/en/httprequest.send.php and modifying it for my own usage, but I can't figure out what's going wrong.

Here's what I have:

<!DOCTYPE html>
<html>
<head>
<title>attack test</title>
</head>
<body>
<?php
$r = new HttpRequest('http://sitename.us', HttpRequest::METH_POST);
try {
    $r->send();
    echo $r->getResponseCode();
} catch (HttpException $ex) {
    echo $ex;
}
?>
</body>
</html>

And here's my understanding of what it should do:

Create an instance of an HttpRequest variable for the URL http://feucht.us and request type METH_POST.

Try to send the request and print the response code. If there's an exception of type HttpException, print it.

Either way, something should get printed, but when I run the script nothing is printed.

Any help?

user3566398
  • 255
  • 1
  • 2
  • 8
  • 2
    So you want us to help you create a comment spam bot ? –  Apr 28 '14 at 18:05
  • Yes, sir. It's just a prank on my friend. – user3566398 Apr 28 '14 at 18:08
  • Do you have http extension installed? http://www.php.net/manual/en/http.install.php – Ziumin Apr 28 '14 at 18:09
  • cURL might be handy, pretty beast library (also multicurl). – sunshinejr Apr 28 '14 at 18:16
  • @Ziumin: Do I have to download a library??? That site is making me download a .tgz file which would require me downloading a program to read .tgz files. Blah. – user3566398 Apr 28 '14 at 18:20
  • A completely empty page usually means you have a "fatal error" on your script. See this answer: http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php/12772851#12772851 If it is a problem with not having the extension installed, CURL (and [the PHP functions to use it](http://php.net/curl)) will probably be installed by default; they're a bit awkward to use, but you should be able to find plenty of examples online which you can adapt to your "needs". – IMSoP Apr 28 '14 at 18:32

1 Answers1

0

From here

<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
//

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.phtml");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "postvar1=value1&postvar2=value2&postvar3=value3");

// in real life you should use something like:
// curl_setopt($ch, CURLOPT_POSTFIELDS, 
//          http_build_query(array('postvar1' => 'value1')));

// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$server_output = curl_exec ($ch);

curl_close ($ch)
Timur
  • 639
  • 6
  • 21