Example #1
0
 function Execute()
 {
     $this->SetOption(CURLOPT_URL, $this->BuildUrl());
     if ($this->method->Equals(Http\RequestMethod::Post())) {
         if (count($this->postParams) > 0) {
             $this->SetOption(CURLOPT_POSTFIELDS, $this->postParams);
         } else {
             $this->SetOption(CURLOPT_POSTFIELDS, $this->postData);
         }
     }
     $this->SetHeaders();
     $result = curl_exec($this->ch);
     $errNo = $this->GetErrorNo();
     if ($errNo) {
         throw new \Exception($this->GetError(), $errNo);
     }
     return $result;
 }
Example #2
0
 /**
  * Returns GET or POST data array
  * @param RequestMethod $method The request method
  * @param string $name Optional parameter name
  * @return array Returns either the full request array or an array filtered by name
  * @throws \InvalidArgumentException Raises an error if method is neither post nor get
  */
 static function MethodArray(RequestMethod $method, $name = '')
 {
     switch ($method) {
         case RequestMethod::Get():
             return self::GetArray($name);
         case RequestMethod::Post():
             return self::PostArray($name);
         default:
             throw new \InvalidArgumentException('Request::MethodArray is available for request methods POST and GET, only');
     }
 }
Example #3
0
 /**
  * Gets the http method for the form; can be overridden for GET forms
  * @return RequestMethod The HTTP method of the form (post or get)
  */
 protected function Method()
 {
     return RequestMethod::Post();
 }