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: HttpRequest.php,v 1.2 2004/10/29 21:23:06 schst Exp $
20
 
21
/**
22
 * Services/Ebay/Transport/HttpRequest.php
23
 *
24
 * Send a request via PEAR::HTTP_Request
25
 *
26
 * @package  Services_Ebay
27
 * @author   Stephan Schmidt <schst@php.net>
28
 */
29
 
30
/**
31
 * needs HTTP_Request
32
 */
33
require_once 'HTTP/Request.php';
34
 
35
/**
36
 * Services/Ebay/Transport/HttpRequest.php
37
 *
38
 * Send a request via PEAR::HTTP_Request
39
 *
40
 * @package  Services_Ebay
41
 * @author   Stephan Schmidt <schst@php.net>
42
 */
43
class Services_Ebay_Transport_HttpRequest
44
{
45
   /**
46
    * send a request
47
    *
48
    * @access   public
49
    * @param    string  uri to send data to
50
    * @param    string  body of the request
51
    * @param    array   headers for the request
52
    * @return   mixed   either
53
    */
54
    function sendRequest( $url, $body, $headers )
55
    {
56
        $params  = array(
57
                         'method'  => 'POST',
58
                         'timeout' => 30
59
                        );
60
        $request = new HTTP_Request($url);
61
 
62
        foreach ($headers as $name => $value) {
63
            $request->addHeader($name, $value);
64
        }
65
        $request->addRawPostData($body);
66
 
67
        $result = $request->sendRequest();
68
        if (PEAR::isError($result)) {
69
            throw new Services_Ebay_Transport_Exception('Could not send request.');
70
        }
71
 
72
        $response = $request->getResponseBody();
73
        return $response;
74
    }
75
}
76
?>