Jump to content


fsockopen first time use

  • Please log in to reply
No replies to this topic

#1 JMorjaria

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 24 July 2006 - 01:20 PM

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?


$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");

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users