Issue 3 - 16 August 2009 Go Back

PHP equivalent to CreateObject("WinHttp.WinHttpRequest.5.1")

The simple answer is: "There is no equivalent to it". WinHttp is Windows API and PHP does not support it. But there are a couple of php specific functions to do similar requests. You can use either fsockopen or cURL functions (require installation). I will show here only the first one which I applied to send a request with some parameters. The SendSMS function is used to send SMS message to a mobile number.


function SendSMS($mobileNumber,$message) {

global $user,$password,$url;

$username = SMS_USERNAME;
$password = SMS_password;
$senderID = SMS_senderID;

$url = 'uname='.$username;
$url.= '&pword='.$password;
$url.= '&msg='.urlencode($msg);
$url.= '&to='.$mobileNumber;
$url.= '&from='.$senderID;

$httpurl = "";

//Open the URL to send the message

$pattern = "/http...([0-9a-zA-Z-.]*).([0-9]*).(.*)/";
$in = "";

//echo "args[1]: <br>$args[1]<br><br>";
//echo "args[2]: <br>$args[2]<br><br>";
//echo "args[3]: <br>$args[3]<br><br>";

$fp = fsockopen($httpurl, 80, $errno, $errstr, 30);
if (!$fp) {
return("$errstr ($errno)");
else {

$out = "GET /$Get HTTP/1.1\r\n";
$out .= "Host: $args[1] \r\n";
$out .= "Accept: */*\r\n";
$out .= "Connection: Close\r\n\r\n";

fwrite($fp, $out);
while (!feof($fp)) {
$in.=fgets($fp, 128);

$response = $in ;
echo "Response: <br><pre>".


I hope this helps especially to those ones who are converting ASP code to PHP. That's what I needed to do and I coule not find any relevant topics.

© 2011 E-SIGHT PTY.LTD. Mentone Vic 3194 Melbourne                   ::PHP equivalent to CreateObject("WinHttp.WinHttpRequest.5.1") :: |    Home    |    Contact Us    |    Sitemap    |