Advertisement
bueddl

Untitled

Sep 27th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * WimbledonComProvider Class
  5.  *
  6.  * Provider for Newsletterregistration at http://www.wimbledon.com
  7.  *
  8.  */
  9.  
  10. class WimbledonComProvider extends FormSubmitter {
  11.  
  12.     /**
  13.      * @var String url to submit the form to
  14.      */
  15.     protected $url = 'http://www.wimbledon.com/en_GB/contact/register.html';
  16.  
  17.     /**
  18.      * @var String http method to use for submit
  19.      */
  20.     protected $method = 'POST';
  21.  
  22.     /**
  23.      *  Populate the form_data array
  24.      *
  25.      * @param String $email email to be used
  26.      */
  27.     protected function fill($email) {
  28.  
  29.         /* Default form fields */
  30.         $this->addField('Email Address', $email);
  31.         $this->addField('Full Name', 'Name');
  32.         $this->addField('Country', 'United Kingdom');
  33.         $this->addField('Email Type', 'HTML');
  34.  
  35.         /* CSRR */
  36.         $response = $this->get($this->url);
  37.  
  38.         $form = $response['form'];
  39.  
  40.         $this->addField('lid', $form['lid']);
  41.         $this->addField('MID', $form['MID']);
  42.  
  43.         /* Submit */
  44.         $this->addField('submit', 'submit');
  45.     }
  46.  
  47.     /**
  48.      * Check response for success
  49.      *
  50.      * @param Array $headers associative arrays of http response headers
  51.      * @param String $data http response data
  52.      */
  53.     protected function check($headers, $data, $url) {
  54.  
  55.         if ( preg_match('/.*register_error\.html.*/', $url) )
  56.             return FormSubmitter::fail;
  57.  
  58.         if ( preg_match('/.*register_complete\.html.*/', $url) )
  59.             return FormSubmitter::success;
  60.  
  61.  
  62.         return FormSubmitter::unknown;
  63.     }
  64.  
  65. }
  66.  
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement