Overview

Packages

  • Date
  • None
  • Service
    • Scribd

Classes

  • Horde_Service_Scribd
  • Horde_Service_Scribd_Request
  • Horde_Service_Scribd_Response
  • Horde_Service_Scribd_Result
  • Horde_Service_Scribd_ResultSet

Exceptions

  • Horde_Service_Scribd_Exception
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
 4:  *
 5:  * @author   Chuck Hagenbuch <chuck@horde.org>
 6:  * @license  http://www.horde.org/licenses/bsd BSD
 7:  * @category Horde
 8:  * @package  Service_Scribd
 9:  */
10: 
11: /**
12:  * Scribd request class
13:  *
14:  * @author   Chuck Hagenbuch <chuck@horde.org>
15:  * @license  http://www.horde.org/licenses/bsd BSD
16:  * @category Horde
17:  * @package  Service_Scribd
18:  */
19: class Horde_Service_Scribd_Request
20: {
21:     protected $_args = array();
22:     protected $_config = array();
23:     protected $_method;
24: 
25:     public function __construct($method, $args = array())
26:     {
27:         $this->_method = $method;
28:         $this->_args = $args;
29:     }
30: 
31:     public function run()
32:     {
33:         $args = array_merge(
34:             $this->_args,
35:             $this->_config,
36:             array(
37:                 'method' => $this->_method,
38:             )
39:         );
40:         if (!empty($this->_config['api_secret'])) {
41:             $args['api_sig'] = $this->_sign($args);
42:         }
43: 
44:         $client = Horde_Service_Scribd::getHttpClient();
45:         $response = $client->post(Horde_Service_Scribd::ENDPOINT, $args);
46:         return new Horde_Service_Scribd_Response($response->getBody());
47:     }
48: 
49:     /**
50:      * @param array  $config
51:      */
52:     public function setConfig($config)
53:     {
54:         $this->_config = $config;
55:     }
56: 
57:     /**
58:      * @param array  $args
59:      */
60:     protected function _sign($args)
61:     {
62:         $signature = $this->_config['api_secret'];
63:         ksort($args);
64:         foreach ($args as $k => $v) {
65:             $signature .= $k . $v;
66:         }
67: 
68:         return hash('md5', $signature);
69:     }
70: 
71: }
72: 
API documentation generated by ApiGen