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 Funções
Índice
- stream_bucket_append — Append bucket to brigade
- stream_bucket_make_writeable — Return a bucket object from the brigade for operating on
- stream_bucket_new — Create a new bucket for use on the current stream
- stream_bucket_prepend — Prepend bucket to brigade
- stream_context_create — Create a streams context
- stream_context_get_default — Retreive the default streams context
- stream_context_get_options — Retrieve options for a stream/wrapper/context
- stream_context_set_default — Set the default streams context
- stream_context_set_option — Sets an option for a stream/wrapper/context
- stream_context_set_params — Set parameters for a stream/wrapper/context
- stream_copy_to_stream — Copies data from one stream to another
- stream_encoding — Set character set for stream encoding
- stream_filter_append — Attach a filter to a stream
- stream_filter_prepend — Attach a filter to a stream
- stream_filter_register — Register a stream filter implemented as a PHP class derived from php_user_filter
- stream_filter_remove — Remove a filter from a stream
- stream_get_contents — Reads remainder of a stream into a string
- stream_get_filters — Retrieve list of registered filters
- stream_get_line — Gets line from stream resource up to a given delimiter
- stream_get_meta_data — Retrieves header/meta data from streams/file pointers
- stream_get_transports — Retrieve list of registered socket transports
- stream_get_wrappers — Retrieve list of registered streams
- stream_notification_callback — A callback function for the notification context paramater
- stream_register_wrapper — Sinônimo de stream_wrapper_register
- stream_resolve_include_path — Determine what file will be opened by calls to fopen with a relative path
- stream_select — Runs the equivalent of the select() system call on the given arrays of streams with a timeout specified by tv_sec and tv_usec
- stream_set_blocking — Set blocking/non-blocking mode on a stream
- stream_set_timeout — Set timeout period on a stream
- stream_set_write_buffer — Sets file buffering on the given stream
- stream_socket_accept — Accept a connection on a socket created by stream_socket_server
- stream_socket_client — Open Internet or Unix domain socket connection
- stream_socket_enable_crypto — Turns encryption on/off on an already connected socket
- stream_socket_get_name — Retrieve the name of the local or remote sockets
- stream_socket_pair — Creates a pair of connected, indistinguishable socket streams
- stream_socket_recvfrom — Receives data from a socket, connected or not
- stream_socket_sendto — Sends a message to a socket, whether it is connected or not
- stream_socket_server — Create an Internet or Unix domain server socket
- stream_socket_shutdown — Shutdown a full-duplex connection
- stream_supports_lock — Tells wether the stream supports locking.
- stream_wrapper_register — Register a URL wrapper implemented as a PHP class
- stream_wrapper_restore — Restores a previously unregistered built-in wrapper
- stream_wrapper_unregister — Unregister a URL wrapper
User Contributed Notes
Stream Funções
Stream Funções
kburkholder at earthasylum dot com
10-Mar-2008 07:43
10-Mar-2008 07:43
marcus at synchromedia dot co dot uk
15-Nov-2007 09:13
15-Nov-2007 09: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 03:16
30-Oct-2006 03: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 12:59
16-May-2006 12: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.

Exemplos