PageRenderTime 16ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/inc/class.account.php

http://php-twitter.googlecode.com/
PHP | 124 lines | 46 code | 12 blank | 66 comment | 4 complexity | fbc7fb577abac4ed8405ef8de332107a MD5 | raw file
  1<?php
  2/**
  3 * Twitter_Account_Name
  4 *
  5 * @package php-twitter 2.0
  6 * @subpackage users
  7 * @author Aaron Brazell
  8 **/
  9
 10class Twitter_Account_Name extends Twitter {
 11	/**
 12	 * Setup Twitter client connection details
 13	 *
 14	 * Ensure you set a user agent, whether via the constructor or by assigning a value to the property directly.
 15	 * Also, if you are not running this from the Eastern timezone, be sure to set your proper timezone.
 16	 *
 17	 * @access public
 18	 * @since 2.0
 19	 * @return Twitter_Account_Name
 20	 */
 21	public function __construct( $username = null, $password = null, $user_agent = null, $headers = null, $timezone = 'America/New_York')
 22	{
 23		parent::__construct($username, $password, $user_agent, $headers, $timezone);
 24	}
 25
 26	/**
 27	 * Verify whether supplied Twitter credentials are correct. Not rate-limited.
 28	 *
 29	 * @access public
 30	 * @since 2.0
 31	 * @return boolean
 32	 */
 33	public function verify_account()
 34	{
 35		$this->api_url = 'http://twitter.com/account/verify_credentials.' . $this->type;
 36		if( is_wp_error( $this->_get( $this->api_url ) ) )
 37			return false;
 38		
 39		return true;
 40	}
 41	
 42	/**
 43	 * Return information about the authenticating users rate limit status
 44	 *
 45	 * @access public
 46	 * @since 2.0
 47	 * @return object
 48	 **/
 49	public function ratelimit()
 50	{
 51		$this->api_url = 'http://twitter.com/account/rate_limit_status.' . $this->type;
 52		return $this->_get( $this->api_url );
 53	}
 54	
 55	/**
 56	 * Ends authenticating user session. 
 57	 *
 58	 * @access public
 59	 * @since 2.0
 60	 * @return boolean
 61	 **/
 62	public function end()
 63	{
 64		$this->api_url = 'http://twitter.com/account/end_session.' . $this->type;
 65		if( $this->_get( $this->api_url ) == null )
 66			return true;
 67			
 68		return false;
 69	}
 70	
 71	/**
 72	 * Update message delivery device. Limited to SMS at this time
 73	 *
 74	 * @access public
 75	 * @since 2.0
 76	 * @param string $device_type. Required. 'sms' or 'none'. Defaults to 'none'
 77	 * @return object
 78	 **/
 79	public function update_device( $device_type = 'none' )
 80	{
 81		if( !in_array( $device_type, array('sms', 'none') ) )
 82			return false;
 83			
 84		$data = array();
 85		$data['device'] = $device_type;
 86		
 87		$this->api_url = 'http://twitter.com/account/update_delivery_device.' . $this->type . $this->_glue( $data );
 88		return $this->_post( $this->api_url );
 89	}
 90	
 91	/**
 92	 * Update profile colors for authenticating user
 93	 *
 94	 * @access public
 95	 * @since 2.0
 96	 * @param array $args. Optional. Pass 3 charachter or 6 charachter hex color codes for each optional parameter
 97	 *  - profile_background_color
 98	 *  - profile_text_color
 99	 *  - profile_link_color
100	 *  - profile_sidebar_color
101	 *  - profile_sidebar_border_color
102	 * @return object
103	 **/
104	public function update_colors( $args = array() )
105	{
106		$defaults = array(
107			'profile_text_color' 			=> '#000000'
108			'profile_sidebar_border_color'	=> '#000'
109			);
110		$args = wp_parse_args( $default, $args );
111		
112		$this->api_url = 'http://twitter.com/account/update_profile_colors.' . $this->type;
113		return $this->_post( $this->api_url, $args );
114	}
115
116	/**
117	 * Destroys the object
118	 *
119	 * @access public
120	 * @since 2.0
121	 * @return null
122	 */
123	public function __destruct() {}
124}