cescentman
asked on
Not sure how to progress this PHP problem
I'm trying to connect to an API using the code I was given for the purpose below. It fails on line 9 with the error:-
"Fatal error: Using $this when not in object context"
Can someone help me understand how to resolve this?
Thanks
"Fatal error: Using $this when not in object context"
Can someone help me understand how to resolve this?
Thanks
function get_response($res) {
$size_packed = fread($res, 4);
if(strlen($size_packed) == 0) { return; }
$size = unpack("N", $size_packed);
// This works around PHP's fread() capping at 8192 bytes
$out = "";
$last = "";
for($s = $size[1]-4; $s>0; $s-=strlen($last)) {
$last = fread($this->res, $s);
$out.=$last;
}
return $out;
}
$api_host = "api.domain.com";
$api_port = 1701;
$clID = "MyID";
$pw = "MyPassword";
$res = fsockopen("tls://" . $api_host, $api_port);
get_response($res);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.