Jump to content


This topic is now archived and is closed to further replies.


fsockopen first time use

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?


[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

// 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]

Share this post

Link to post
Share on other sites


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.