Ik wil teletekst met een PHP script lezen (onderstaand)
maar ik krijg een 'access denied' fout ....
Heeft de NOS soms de pagina beveiligd tegen toegang vanuit scripts ?
---------------------------
<?php
// send wml headers
/* sendToHost
* ~~~~~~~~~~
* Params:
* $host - Just the hostname. No http:// or /path/to/file.html portions
* $method - get or post, case-insensitive
* $path - The /path/to/file.html part
* $data - The query string, without initial question mark
* $useragent - If true, 'MSIE' will be sent as the User-Agent (optional)
*
* Examples:
* sendToHost('www.google.com','get','/search','q=ditz');
* sendToHost('www.example.com','post','/some_script.cgi',
* 'param=First+Param&second=Second+param');
*/
function sendToHost($host,$method,$path,$data,$useragent=0)
{
// Supply a default method of GET if the one passed was empty
$buf = "";
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80);
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: MSIE\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
function teletextentry($page, $subpage, $extra='')
{
$sub = sprintf("$page-%02d.html", $subpage);
// $buf = sendToHost('teletekst.nos.nl','get','/tekst/',$sub);
$buf = sendToHost('teletekst.nos.nl','get','','');
echo $buf; exit;
?>
------------------------------------
Heb ook ff geprobeerd in de root directory teletekst.nos.nl ook die weigert :-((
Geeft de volgende uitvoer:
-----------------------------------------------------------------------
<?xml version="1.0"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN"
"http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<card id="KPN" title="Telefoongids">
<p>
Pagina:
<input title="pagina" name="page" maxlength="32" value="703"/> <br/>
<anchor>
<go href="/wap/klaas/teletekst.php" method="get">
<postfield name="page" value="$page"/>
</go>
Zoek op
</anchor>
HTTP/1.1 403 Forbidden
Date: Sat, 18 Jan 2003 18:44:13 GMT
Server: Apache/2.0.43 (Unix)
Content-Length: 202
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /
on this server.</p>
</body></html>
--------------------------------------------------------------------------
Weet iemand wat hier misgaat ?
Klaas

Likes:

Quote