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