CaptchaRequiredException.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage App
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see Zend_Gdata_App_CaptchaRequiredException
  23. */
  24. require_once 'Zend/Gdata/App/AuthException.php';
  25. /**
  26. * Gdata exceptions
  27. *
  28. * Class to represent an exception that occurs during the use of ClientLogin.
  29. * This particular exception happens when a CAPTCHA challenge is issued. This
  30. * challenge is a visual puzzle presented to the user to prove that they are
  31. * not an automated system.
  32. *
  33. * @category Zend
  34. * @package Zend_Gdata
  35. * @subpackage App
  36. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. class Zend_Gdata_App_CaptchaRequiredException extends Zend_Gdata_App_AuthException
  40. {
  41. /**
  42. * The Google Accounts URL prefix.
  43. */
  44. const ACCOUNTS_URL = 'https://www.google.com/accounts/';
  45. /**
  46. * The token identifier from the server.
  47. *
  48. * @var string
  49. */
  50. private $captchaToken;
  51. /**
  52. * The URL of the CAPTCHA image.
  53. *
  54. * @var string
  55. */
  56. private $captchaUrl;
  57. /**
  58. * Constructs the exception to handle a CAPTCHA required response.
  59. *
  60. * @param string $captchaToken The CAPTCHA token ID provided by the server.
  61. * @param string $captchaUrl The URL to the CAPTCHA challenge image.
  62. */
  63. public function __construct($captchaToken, $captchaUrl) {
  64. $this->captchaToken = $captchaToken;
  65. $this->captchaUrl = Zend_Gdata_App_CaptchaRequiredException::ACCOUNTS_URL . $captchaUrl;
  66. parent::__construct('CAPTCHA challenge issued by server');
  67. }
  68. /**
  69. * Retrieves the token identifier as provided by the server.
  70. *
  71. * @return string
  72. */
  73. public function getCaptchaToken() {
  74. return $this->captchaToken;
  75. }
  76. /**
  77. * Retrieves the URL CAPTCHA image as provided by the server.
  78. *
  79. * @return string
  80. */
  81. public function getCaptchaUrl() {
  82. return $this->captchaUrl;
  83. }
  84. }