Connecting Tech Pros Worldwide Forums | Help | Site Map

Warning: fsockopen() [function.fsockopen]: unable to connect to

Newbie
 
Join Date: Nov 2008
Posts: 1
#1: Nov 6 '08
I am working on a script and i get this error

Warning: fsockopen() [function.fsockopen]: unable to connect to https://www.alertpay.com:443 (Unable to find the socket transport "https" - did you forget to enable it when you configured PHP?) in XXXXXXXXXXXXXX on line 84

I have contacted my host to make sure that ssl and all that is enabled he says it has been enabled and it still dont work

here is my server info
http://www.performancebux.com/info.php

If any one see what that problem is please let me know how to maybe fix it and maybe how to get it to work here is a copy of the php code that i am using to witch is causeing the problem

Expand|Select|Wrap|Line Numbers
  1. class CYsHttpClass
  2. {
  3.     protected $cookies, $postdata,$r_header,$r_content,$s_request;
  4.     final protected function addCookie($k, $v)
  5.     {
  6.         if(is_array($k))
  7.             for($i=0;$i<sizeof($k);$i++)
  8.                 $this->cookies[$k[$i]] = $v[$i];
  9.         else
  10.             $this->cookies[$k] = $v;
  11.     }
  12.     final protected function addPostData($k, $v)
  13.     {
  14.         if(is_array($k))
  15.             for($i=0;$i<sizeof($k);$i++)
  16.                 $this->postdata[$k[$i]] = $v[$i];
  17.         else
  18.             $this->postdata[$k] = $v;
  19.     }
  20.     final protected function httpConnect($url,$method='GET',$referer='',$useragent='PayChain')
  21.     {
  22.         $port = 80; //Set Default Port to 80
  23.         $method = strtoupper($method);
  24.  
  25.         list($protocol,$server,$script) = preg_split("/(http|https)?:\/\/([^\/]+)([^ ]*)/",$url,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  26.  
  27.         if($protocol=="https")
  28.             $port = 443;
  29.  
  30.         if(strpos($server,":") != false)
  31.             list($server,$port) = preg_split("/([^:]+):(.+)/",$server,-1,PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  32.  
  33.         $cookiestring = "";
  34.         if(is_array($this->cookies))
  35.             if(sizeof($this->cookies) > 0)
  36.                 foreach($this->cookies as $key=>$value)
  37.                 {
  38.                     if(strlen($cookiestring) != 0)
  39.                         $cookiestring .= '; ';
  40.                     $cookiestring .= urlencode($key) . '=' . urlencode($value);
  41.                 }
  42.  
  43.         $postdatastring = "";
  44.         if(is_array($this->postdata))
  45.         {
  46.             $postdatastring = "";
  47.             if(sizeof($this->postdata) > 0)
  48.                 foreach($this->postdata as $key=>$value)
  49.                 {
  50.                     if(strlen($postdatastring) != 0) $postdatastring .= '&';
  51.                     $postdatastring .= urlencode($key) . '=' . urlencode($value);
  52.                 }
  53.         }
  54.  
  55.         $this->postdata = array(); // reset postdata field after use
  56.  
  57.         $this->s_request="$method $script HTTP/1.1\r\n";
  58.         $this->s_request.="Host: $server\r\n";
  59.         $this->s_request.="Accept: */*\r\n";
  60.         if($cookiestring)
  61.             $this->s_request.="Cookie: $cookiestring\r\n";
  62.         if($referer)
  63.             $this->s_request.="Referer: $referer\r\n";
  64.         if($useragent)
  65.             $this->s_request.="User-Agent: $useragent\r\n";
  66.  
  67.         $this->s_request.="Connection: close\r\n";
  68.  
  69.         if($method == "POST")
  70.         {
  71.             $this->s_request.="Content-Type: application/x-www-form-urlencoded\r\n";
  72.             $this->s_request.="Content-Length: ".strlen($postdatastring)."\r\n";
  73.             $this->s_request.="\r\n$postdatastring\r\n";
  74.         }
  75.         else
  76.             $this->s_request.="\r\n";
  77.  
  78.         $sock = fsockopen(($protocol=="https"? "ssl://".$server : $server), $port, $errno, $errstr);
  79.         if($sock)
  80.             fwrite($sock, $this->s_request);
  81.         else
  82.         {
  83.             $this->r_header = "$errstr ($errno)";
  84.             return -1;
  85.         }
  86.  
  87.         $this->r_header = "";
  88.         while($str = trim(fgets($sock, 4096)))
  89.             $this->r_header .= "$str\n";
  90.  
  91.         if(preg_match_all("/Set-Cookie: (.*); path/", $this->r_header, $newcookie))
  92.             foreach($newcookie[1] as $c)
  93.             {
  94.                 list($k,$v) = explode("=", $c);
  95.                 $this->cookies[$k] = $v;
  96.             }    
  97.  
  98.         $this->r_content = "";
  99.         while(1)
  100.         {
  101.             $buf = fread($sock,8192);
  102.             if(strlen($buf) == 0) break;
  103.             $this->r_content .= $buf;
  104.         }
  105. //        echo("DEBUG:".$this->r_content);
  106.     }
  107. }
  108.  

please if any can give some advice please let me know

Reply