Jump to content

fsockopen first time use


JMorjaria

Recommended Posts

I have been having some trouble getting this script to work, I think I understand it, I was helped along to make it. The problem is for some reason it runs the script, doesnt do the request and redirects at the bottom, no errors nothing.  I am not that familiar with this, so was hoping someone could point me in the right direction, maybe tell me how to make it error, or spot a mistake?

thanks

[code]$host_name = "www.bulksms.co.uk";
// open a socket on port 80 (HTTP default)
$socket = fsockopen( $host_name , 5567 , $errno , $errstr, 30 ); 

// unable to open a socket?
if (!$socket){
    die('message could not be sent: ' . $errno . '(' . $errstr . ')'); 
}

// get request for the specified PATH
// here's where you'd throw your querystring
$uri_path = "/eapi/submission/send_sms/2/2.0?username=*****&password=*******&routing_group=2&allow_concat_text_sms=1&message=$message&msisdn=$too&sender=$companyname";
$http_header = "GET $uri_path HTTP/1.1\r\n"; 

// write hostname in request, because otherwise we may be denied for
// providing an invalid request

$http_header .= "Host: $host_name\r\n"; 

// thats it, we can close our open push content
$http_header .= "Connection: Close\r\n\r\n";

//write header to the socket, thus making the request
fwrite ( $socket , $http_header );

// while the socket isn't closed, or empty
while (!feof($socket)){
    // append socket results to string
    $file_contents .= fgets($socket, 4096); 
}

// close opened socket to the website
fclose($socket); 

// you can now do anything with the $file_contents variable
// perhaps the url returns a true/false boolean, or an xml
// you can parse to find out if your request was successful 

header("Location: $url");[/code]
Link to comment
Share on other sites

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.