} elseif (!empty($config['username']) && !empty($config['password'])) {
// Http_Basic
$this->_authType = 'Basic';
- $params = array();
+ $params = array('username' => $config['username'],
+ 'password' => $config['password']);
}
$aclass = 'Horde_Service_Twitter_Auth_' . $this->_authType;
--- /dev/null
+<?php
+/**
+ * Horde_Service_Twitter_Auth class to abstract all auth related tasks
+ *
+ * Basically implements Horde_Oauth_Client and passes the calls along to the
+ * protected oauth object.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Service_Twitter
+ */
+class Horde_Service_Twitter_Auth_Basic extends Horde_Service_Twitter_Auth
+{
+ protected static $_authorizationHeader;
+
+ public function buildAuthorizationHeader()
+ {
+ if (empty(self::$_authorizationHeader)) {
+ self::$_authorizationHeader = 'Basic ' . base64_encode($this->username . ':' . $this->password);
+ }
+
+ return self::$_authorizationHeader;
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Horde_Service_Twitter_Request_Oauth class wraps sending requests to Twitter's
+ * REST API using OAuth authentication.
+ *
+ * Copyright 2009 The Horde Project (http://www.horde.org)
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ * @license http://opensource.org/licenses/bsd-license.php BSD
+ * @category Horde
+ * @package Horde_Service_Twitter
+ */
+class Horde_Service_Twitter_Request_Basic extends Horde_Service_Twitter_Request
+{
+
+ protected $_twitter;
+
+ public function __construct($twitter)
+ {
+ $this->_twitter = $twitter;
+ }
+
+ public function get($url, $params = array())
+ {
+ $client = new Horde_Http_Client();
+ $response = $client->get($url, array('Authorization' => $this->_twitter->auth->buildAuthorizationHeader()));
+
+ return $response->getBody();
+ }
+
+ public function post($url, $params = array())
+ {
+ $client = new Horde_Http_Client();
+ $response = $client->post($url, $params, array('Authorization' => $this->_twitter->auth->buildAuthorizationHeader()));
+
+ return $response->getBody();
+ }
+
+}
*/
public function show($id)
{
- $url = $this->_endpoint . '/destroy.' . $this->_format;
+ $url = $this->_endpoint . 'show.' . $this->_format;
return $this->_twitter->request->post($url, array('id' => $id));
}
*/
public function destroy($id)
{
- $url = $this->_endpoint . '/destroy.' . $this->_format;
+ $url = $this->_endpoint . 'destroy.' . $this->_format;
return $this->_twitter->request->post($url, array('id' => $id));
}
*/
public function update($status, $replyTo = '')
{
- $url = $this->_endpoint . '/update.' . $this->_format;
+ $url = $this->_endpoint . 'update.' . $this->_format;
$params = array('status' => $status);
if (!empty($replyTo)) {
$params['in_reply_to_status_id'] = $replyTo;