Jump to content

Recommended Posts

I have this code:

error_reporting(E_ALL);
        $post = array();
        $post['user'] = "ttocskcaj";
        $post['group'] = "Mod";
        $ret = '';
        $postdata_str = "user=" . $post['user'] . "&group=" . $post['group'];
        if (($fp = @fsockopen("www.secret.com", 8101, $errno, $errstr)) == false)
            die("Error $errno: $errstr\n");
        fputs($fp, "POST /permissions-proceed HTTP/1.0\r\n");
        fputs($fp, "Host: www.secret.com:8101");
        fputs($fp, "User-Agent: HTTPTool/1.0\r\n");
        fputs($fp, "Content-Length: 256\r\n\r\n");
        fputs($fp, "$postdata_str");
        while (!feof($fp)) {
            // receive the results of the request
            echo "<pre>".fgets($fp, 128)."</pre>";
        }
        fclose($fp);

Which is supposed to send a username and a group to a python script where the user is put into that group.

It's not working though.

I just want to check if everything is alright on this end, before trying to find what's wrong in the python.

Link to comment
https://forums.phpfreaks.com/topic/239724-http-request-not-working/
Share on other sites

Not sure what I was doing wrong, but I changed it to use cURL and now it works fine :s

 

$survival_curl = curl_init();
curl_setopt($survival_curl, CURLOPT_URL, "http://www.secret.com");
curl_setopt($survival_curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($survival_curl, CURLOPT_POST, true);
curl_setopt($survival_curl, CURLOPT_POSTFIELDS, $data);
$output_survival = curl_exec($survival_curl);
$info_survival = curl_getinfo($survival_curl);
curl_close($survival_curl);

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.