Does this code look correct? -- FSockopen question


#1

Hi folks,

I’ve been asked to program a small section of code that allows other websites to call our page with this code and dump a string of data. After looking at a series of tutorials, I came up with the following:

$sock = fsockopen(“ssl://www.awebsite.com”, 443, $errno, $errstr, 30);
if (!$sock) die("$errstr ($errno)n");
else
{
$exportstring= “”;
fwrite($sock, “n”);
while (!feof($sock))
$exportstring .= fgets($sock, 4096);
fclose($sock);
}

Does this look correct for what i’m trying to accomplish? Is there anything i’m missing? Feel free to improve upon it if there it is not up to snuff. I will be unable to test it for a couple of days but would like to make sure it’s in correct format before I do.
Thanks,

  • Mike

#2

ssl:// shouldn’t be in the url you’re trying to open. That’s just one thing I noticed.