Re: [PHP-ES] Permitir conexion desde PHP a sitio externo

[email protected] (Jonathan Tapicer)
Newsgroups php.general.es
Message-ID <[email protected]>
Hola,

Si usás las funciones para leer archivos (file_get_contents, fopen,
etc) para acceder a los sitios, necesitás pasarle un context con la ip
y el puerto del proxy, por ejemplo:

<?php
$context = stream_context_create(array('http' => array('proxy' =>
'tcp://127.0.0.1:8080', 'request_fulluri' => true)));

$html = file_get_contents("http://www.php.net", false, $context);
?>

En el ejemplo se obtiene el html del sitio www.php.net usando el proxy
127.0.0.1 en el puerto 8080.

Espero que te sirva, saludos,

Jonathan

2010/1/14 ReynierPM <[email protected]>:
> Hola a todos:
> Estoy desarrollando una aplicación la cual necesita acceder a sitios
> externos. El tema es que la aplicación la estoy desarrollando en mi PC y a
> Internet solo puedo acceder a traves de un proxy, existe alguna forma de
> decirle a PHP que use este proxy para abrir conexiones a esos sitios?
> --
> Saludos
> Ing. Reynier Pérez Mira
>
> --
> PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.