/** * You won't normally use this function, but if you just want to pass a fully constructed XML document * to Intacct, then use this function. * * @param String $body a Valid XML string * @param String $endPoint URL to post the XML to * * @throws exception * @return String the raw XML returned by Intacct */ public static function execute($body, $endPoint) { self::$lastRequest = $body; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $endPoint); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 3000); //Seconds until timeout curl_setopt($ch, CURLOPT_POST, 1); // TODO: Research and correct the problem with CURLOPT_SSL_VERIFYPEER curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // yahoo doesn't like the api.intacct.com CA $body = "xmlrequest=" . urlencode($body); curl_setopt($ch, CURLOPT_POSTFIELDS, $body); $response = curl_exec($ch); $error = curl_error($ch); if ($error != "") { throw new Exception($error); } $curlInfo = curl_getinfo($ch); if ($curlInfo['http_code'] != 200) { throw new Exception('HTTP code not 200, got code ' . $curlInfo['http_code'] . ' instead.'); } curl_close($ch); self::$lastResponse = $response; return $response; }