Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?PHP
2
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +----------------------------------------------------------------------+
4
// | PHP Version 4                                                        |
5
// +----------------------------------------------------------------------+
6
// | Copyright (c) 1997-2002 The PHP Group                                |
7
// +----------------------------------------------------------------------+
8
// | This source file is subject to version 2.0 of the PHP license,       |
9
// | that is bundled with this package in the file LICENSE, and is        |
10
// | available at through the world-wide-web at                           |
11
// | http://www.php.net/license/2_02.txt.                                 |
12
// | If you did not receive a copy of the PHP license and are unable to   |
13
// | obtain it through the world-wide-web, please send a note to          |
14
// | license@php.net so we can mail you a copy immediately.               |
15
// +----------------------------------------------------------------------+
16
// | Authors: Stephan Schmidt <schst@php.net>                             |
17
// +----------------------------------------------------------------------+
18
//
19
// $Id: Streams.php,v 1.1 2004/10/28 17:14:53 schst Exp $
20
 
21
/**
22
 * Services/Ebay/Transport/Streams.php
23
 *
24
 * Send a request via streams and a simple file_get_contents
25
 *
26
 * @package  Services_Ebay
27
 * @author   Stephan Schmidt <schst@php.net>
28
 */
29
 
30
/**
31
 * Services/Ebay/Transport/Streams.php
32
 *
33
 * Send a request via streams and a simple file_get_contents
34
 *
35
 * @package  Services_Ebay
36
 * @author   Stephan Schmidt <schst@php.net>
37
 */
38
class Services_Ebay_Transport_Streams
39
{
40
   /**
41
    * send a request
42
    *
43
    * @access   public
44
    * @param    string  uri to send data to
45
    * @param    string  body of the request
46
    * @param    array   headers for the request
47
    * @return   mixed   either
48
    */
49
    function sendRequest( $url, $body, $headers )
50
    {
51
        $headers['Content-Type'] = 'text/xml';
52
        $headers = implode("\r\n", $this->_createHeaders($headers));
53
 
54
        $opts = array(
55
                      'http' => array(
56
                                      'method'  => 'POST',
57
                                      'header'  => $headers,
58
                                      'content' => $body,
59
                                    )
60
                     );
61
 
62
        $context = stream_context_create($opts);
63
 
64
        $result = file_get_contents($url, false, $context);
65
 
66
        return $result;
67
    }
68
 
69
   /**
70
    * create the correct header syntax used by streams context
71
    *
72
    * @access   private
73
    * @param    array       headers as supplied by Services_Ebay
74
    * @return   array       headers as needed by stream_context_create
75
    */
76
    function _createHeaders( $headers )
77
    {
78
        $tmp = array();
79
        foreach ($headers as $key => $value) {
80
            array_push($tmp, "$key: $value");
81
        }
82
        return $tmp;
83
    }
84
}
85
?>