Foros del Web » Programando para Internet » PHP »

problema con clase de phpclasses

Estas en el tema de problema con clase de phpclasses en el foro de PHP en Foros del Web. Estoy tratando de echar a funcionar la clase wikipediaclass.php y me da el siguiente error cuando trato de abrir la url file_get_contents(http://es.wikipedia.org/wiki/historia) [function.file-get-contents]: failed to ...
  #1 (permalink)  
Antiguo 17/10/2007, 06:43
 
Fecha de Ingreso: febrero-2007
Mensajes: 103
Antigüedad: 17 años, 2 meses
Puntos: 0
problema con clase de phpclasses

Estoy tratando de echar a funcionar la clase
wikipediaclass.php y me da el siguiente error
cuando trato de abrir la url

file_get_contents(http://es.wikipedia.org/wiki/historia) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in C:\wamp\www\wikipedia\wikipedia.class.php on line 14

el fichero php

<?PHP
include 'wikipedia.class.php';
$x = new wikipedia('http://es.wikipedia.org/');
echo $x->get_page('historia', true);
?>



y el codigo de la clase

<?PHP
class wikipedia
{
public function __construct($wiki)
{
$this->wiki = $wiki;
}
public function __destruct()
{
unset($this->wiki);
}
public function get_page($name, $header = false)
{
$file = file_get_contents($this->wiki.'wiki/'.$name);
$file = str_replace('href="/', 'href="'.$this->wiki.'/', $file);
//$file = str_replace('href="#', 'href="'.$this->wiki.'/wiki/'.$name.'#', $file);
preg_match_all('#<!-- start content -->(.*?)<!-- end content -->#es', $file, $ar);
unset($file);
IF(is_array($ar[1]))
{
IF($header == false)
{
return $ar[1][0];
}
else
{
return '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl" dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="'.$this->wiki.'/skins-1.5/monobook/main.css" /></head><body>'.$ar[1][0];
}
}
else
{
return false;
}
}
public function edit_page($name, $header = false)
{
$file = file_get_contents($this->wiki.'/w/index.php?title='.$name.'&action=edit');
preg_match_all('#<textarea (.*?)ols=\'80\' >(.*?)</textarea>#es', $file, $ar);
unset($file);
IF(is_array($ar[2]))
{
ob_start();
IF($header != false)
{
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl" dir="ltr"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="'.$this->wiki.'/skins-1.5/monobook/main.css" /></head><body>';
}

$xname = 'wpTextbox1';
echo '<Form action="'.$this->wiki.'/w/index.php?title='.$name.'&amp;action=submit" METHOD="POST" enctype="multipart/form-data" name="rk" id="editform"><center>
<script language="JavaScript">
function emoticon('.$xname.') {
'.$xname.' = \'\' + '.$xname.' + \'\';
if (document.rk.'.$xname.'.create'.$xname.'Range && document.rk.'.$xname.'.caretPos) {
var caretPos = document.rk.'.$xname.'.caretPos;
caretPos.'.$xname.' = caretPos.'.$xname.'.charAt(caretPos.'.$xname.'.len gth - 1) == \' \' ? '.$xname.' + \' \' : '.$xname.';
document.rk.'.$xname.'.focus();
} else {
document.rk.'.$xname.'.value += '.$xname.';
document.rk.'.$xname.'.focus();
}
}
</script>';

echo '<center><textarea cols="75" rows="30" name="'.$xname.'">'.$ar[2][0].'</textarea><BR>
<input type="button" value="Link to a wiki page" onClick="javascript:emoticon(\'[[wiki_page]]\')">
<input type="button" value="Link" onClick="javascript:emoticon(\'[http://your_url.pl Page Title]\')">
<input type="button" value="Graphic" onClick="javascript:emoticon(\'[[Grafika:filename]]\')">
<input type="button" value="H1 - Big Title" onClick="javascript:emoticon(\'= Title =\')">
<input type="button" value="H2 - Medium Title" onClick="javascript:emoticon(\'== Title ==\')">
<input type="button" value="H3 - Small Title" onClick="javascript:emoticon(\'=== Title ===\')">
<input type="button" value="LI - lists" onClick="javascript:emoticon(\'* Text here\')">
<input type="button" value="LI - numeric lists" onClick="javascript:emoticon(\'# Text here\')">
<input type="button" value="Definition" onClick="javascript:emoticon(\'; Definition name : Description\')">
<input type="button" value="HR - line" onClick="javascript:emoticon(\'----\')"><BR><BR>';

echo '<BR><input tabindex=\'5\' id=\'wpSave\' type=\'submit\' value="Save" name="wpSave" accesskey="s">
<input tabindex=\'6\' id=\'wpPreview\' type=\'submit\' value="Preview" name="wpPreview" accesskey="p">
<input tabindex=\'7\' id=\'wpDiff\' type=\'submit\' value="Preview Changes" name="wpDiff" accesskey="v"></center></form>';
$wynik = ob_get_contents();
ob_end_clean();
return $wynik;
}
else
{
return false;
}
}
}
?>



a que se puede deber este erro, por mas que busco no encuentro
Debe de ser algo que desconosco
  #2 (permalink)  
Antiguo 19/10/2007, 05:57
 
Fecha de Ingreso: febrero-2007
Mensajes: 103
Antigüedad: 17 años, 2 meses
Puntos: 0
Re: problema con clase de phpclasses

No hay nadie que me pueda orientar?
  #3 (permalink)  
Antiguo 19/10/2007, 08:17
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Re: problema con clase de phpclasses

No dupliques temas, este tema ya esta abierto en PHP Orientado a Objetos.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 14:19.