I am not sure if we can connect to netfond API through PHP , because on this link ( http://www.netfonds.no/api.php ) they have given python file as an example and also one PDF which explain their API. But I am using PHP to connect to the API & its not working. after connection I am just getting this response (0 193 "Netfonds Bank AS QUOTE-API version 1.6/20161128 real-time feed") & not able to execute any other command from API.
Here is my code that I tried
$socket = fsockopen( "ssl://nfapi.netfonds.no", rand(8400,8405), $errno, $errstr, 100 );
$str = "(testmode:mode :OK)";
fwrite( $socket, $str );
echo "Reading response:
";
//echo fread( $socket, 4096 );
while (!feof($socket)) {
echo fread( $socket, 4096 );
}
fclose( $socket );
I also tried this code, but same response
$g = stream_context_create (array("ssl" => array("capture_peer_cert" => true)));
// Create the server socket
//$r = stream_socket_server('ssl://nfapi.netfonds.no:'.rand(8400,8405),$errno,$errstr,STREAM_SERVER_BIND|STREAM_SERVER_LISTEN,$g);
$r = stream_socket_client("ssl://nfapi.netfonds.no:".rand(8400,8405), $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $g);
$cont = stream_context_get_params($r);
var_dump($cont["options"]["ssl"]["peer_certificate"]);
$str = "(testmode:mode :OK)";
fwrite($r, $str);
while (!feof($r)) {
echo fread( $r, 4096 );
}
fclose($r);
I have also installed SSL certificate on my server, but still my code is not working.