Example #1
0
 public function apiRequest($method, $vars)
 {
     $req = new Am_HttpRequest(self::API_URL . "/" . $method . ".html", Am_HttpRequest::METHOD_POST);
     $req->addPostParameter('merchantid', $this->getConfig('merchant_id'));
     $req->addPostParameter('signature', $this->getConfig('api_signature'));
     foreach ($vars as $k => $v) {
         $req->addPostParameter($k, $v);
     }
     $req->send();
     $resp = $req->getBody();
     if (!$resp) {
         throw new Am_Exception_InputError('PWC: got empty response from API server');
     }
     $xml = simplexml_load_string($resp);
     if ($xml->error) {
         throw new Am_Exception_InputError('PWC: Got error from API: ' . $xml->error->errortext);
     }
     return $xml;
 }