I've developed a simple streams class to handle get, post and put requests (based on the documentation and user notes here).
The simplest example:
<?php
// a simple GET request:
include('eac_streams.class.php');
$http = new stream();
$result = ('http://www.domain.com/somepage.php');
?>
Along with that, I have a curl class that does nearly the same thing.
http://www.kevinburkholder.com/sw_curl_stream.php
Hope it's useful. Any feedback is welcomed.
Thanks.
[note: cross-posted to curl page]
Stream Functions
Table of Contents
- stream_bucket_append — Anexar cubo a una brigada
- stream_bucket_make_writeable — Devolver un objeto tipo cubo de una brigada para operar sobre él
- stream_bucket_new — Crear un nuevo cubo para su uso en la secuencia actual
- stream_bucket_prepend — Agregar un cubo al comienzo de una brigada
- stream_context_create — Crear un contexto de secuencia
- stream_context_get_default — Recuperar el contexto de secuencias predeterminado
- stream_context_get_options — Recuperar las opciones para una secuencia/envoltura/contexto
- stream_context_set_default — Set the default streams context
- stream_context_set_option — Establece una opción para una secuencia/envoltura/contexto
- stream_context_set_params — Establecer parámetros para una secuencia/envoltura/contexto
- stream_copy_to_stream — Copia datos desde una secuencia a otra
- stream_encoding — Set character set for stream encoding
- stream_filter_append — Adjuntar un filtro a una secuencia
- stream_filter_prepend — Adjuntar un filtro a una secuencia
- stream_filter_register — Registrar un filtro de secuencia implementado como una clase PHP derivada de php_user_filter
- stream_filter_remove — Remover un filtro de una secuencia
- stream_get_contents — Lee el resto de una secuencia en una cadena
- stream_get_filters — Recuperar la lista de filtros registrados
- stream_get_line — Obtiene una línea desde un recurso de secuencia, hasta un delimitador dado
- stream_get_meta_data — Recupera meta datos/cabeceras desde apuntadores a secuencias/archivos
- stream_get_transports — Recuperar la lista de transportes de socket registrados
- stream_get_wrappers — Recuperar la lista de secuencias registradas
- stream_notification_callback — A callback function for the notification context paramater
- stream_register_wrapper — Alias de stream_wrapper_register
- stream_resolve_include_path — Determine what file will be opened by calls to fopen with a relative path
- stream_select — Ejecuta el equivalente al llamado de sistema select() en la matriz de secuencias dada, con un tiempo de espera especificado por tv_sec y tv_usec
- stream_set_blocking — Establecer modo de bloqueo/no-bloqueo sobre una secuencia
- stream_set_timeout — Establecer el periodo de espera de una secuencia
- stream_set_write_buffer — Establece el uso de búferes de archivo en la secuencia dada
- stream_socket_accept — Aceptar una conexión en un socket creado por stream_socket_server
- stream_socket_client — Abrir una conexión de socket de dominio de Internet o Unix
- stream_socket_enable_crypto — Habilita/deshabilita la encripción sobre un socket ya conectado
- stream_socket_get_name — Recuperar el nombre de los sockets locales o remotos
- stream_socket_pair — Crea un par de secuencias de socket conectados e indistinguibles
- stream_socket_recvfrom — Recibe datos desde un socket, conectado o no
- stream_socket_sendto — Envía un mensaje a un socket, sin importar si está conectado o no
- stream_socket_server — Crear un socket de servidor de dominio de Internet o Unix
- stream_socket_shutdown — Shutdown a full-duplex connection
- stream_wrapper_register — Registrar una envoltura URL implementada como una clase PHP
- stream_wrapper_restore — Recupera una envoltura incorporada, previamente retirada del registro
- stream_wrapper_unregister — Retirar del registro una envoltura de URL
Stream Functions
kburkholder at earthasylum dot com
10-Mar-2008 11:43
10-Mar-2008 11:43
marcus at synchromedia dot co dot uk
16-Nov-2007 12:13
16-Nov-2007 12:13
I can't find any real documentation on the quoted-printable-encode stream filter, but I've gathered info from several places. It seems there are 4 options that can be passed in the param array as in my other note on this subject:
line-length: integer, simply sets line length before a soft break is inserted
line-break-chars: Which char or chars to consider as a line break - note that "\r\n" will only match CRLF, not CR or LF, so make sure it matches your content.
binary: boolean, hex encodes all control chars, including spaces and line breaks, but leaves alphanumerics untouched
force-encode-first: Forcibly hex-encodes the first char on each line, even if it's alphanumeric. This is useful for avoiding corruption in some incompetent mail servers, like Exchange.
marcus at synchromedia dot co dot uk
30-Oct-2006 07:16
30-Oct-2006 07:16
As this article says, there is no quoted_printable_encode function() in PHP: http://www.zend.com/manual/filters.convert.php
However there is a stream filter for quoted printable encoding. Here's an example function that produces output suitable for email and doesn't explicitly use external files (though it might do for strings over 2Mb due to the nature of the temp stream type):
<?php
function quoted_printable_encode($string) {
$fp = fopen('php://temp/', 'r+');
$params = array('line-length' => 70, 'line-break-chars' => "\r\n");
stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
fputs($fp, $string);
rewind($fp);
return stream_get_contents($fp);
}
echo quoted_printable_encode(str_repeat("hello there ", 50)." a=1\r\n")."\n";
?>
The filter needs to be restricted to STREAM_FILTER_READ because by default it will get filtered both going into and out of the stream, and will thus get encoded twice.
It should be much faster than using a PHP implementation of the same thing, though note that this will only work in PHP 5.1+.
jausions at php dot net
16-May-2006 05:59
16-May-2006 05:59
For the "notification" index of the $params for stream_context_set_params() function, a callable function is accepted. That is array(&$object, 'methodName') will also work.
