Guest User

Untitled

a guest
May 4th, 2015
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <?php
  2. class yandexCaptcha {
  3. public $key;
  4.  
  5. public function __construct($key) {
  6. $this->key = $key;
  7. }
  8. public function get() {
  9. $type = "std";
  10. $xmlResponse = file_get_contents("http://cleanweb-api.yandex.ru/1.0/get-captcha?key=".$this->key."&type=".$type);
  11. $xml = simplexml_load_string($xmlResponse);
  12. return array('url' => $xml->url, 'code' => $xml->captcha);
  13. }
  14. public function send($captchaCode, $captchaValue) {
  15. $xmlResponse = file_get_contents("http://cleanweb-api.yandex.ru/1.0/check-captcha?key=".$this->key."&captcha=".$captchaCode."&value=".$captchaValue);
  16. $xml = new SimpleXMLElement ($xmlResponse);
  17. $result = $xml->children();
  18. return $result->getName();
  19. }
  20. }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment