Our clients are sending documents to a third party and they are storing it. A soon as the third party receives the documents, they send xml data to our url we provide them (ex. http://ift.tt/1Es7hLT). Our third party requires us to sending them back a response say we received their request. We created a vendor library and have it autoloading into our app. For some reason, when we fake the request from the 3rd party, we are getting redirect back to our log in page as if nothing happened. This is our controller.
class DocumentsController extends AppController {
public function beforeFilter(Event $event) {
parent::beforeFilter($event);
$this->Security->config('unlockedActions', ['receive']);
$this->Auth->allowedActions = (['receive']);
}
public function receive()
{
$this->request->allowMethod(['post']);
$this->autoRender = false;
$doc = new \Document\Document(false);
$doc->set_user_name("username");
$doc->set_user_password("password");
$xml = $this->request->data['xml'];
try {
if($doc->parse_inbound_message($xml)) {
$parsed = $doc->getContent();
$file = new File('files/playground/test_file.xml', true, 0644);
$file->open();
//$file->write(print_r($parsed, true));
$file->write('Hey, I parsed!');
$file->close();
} else {
$file = new File('files/playground/test_file.xml', true, 0644);
$file->open();
$file->write('we got a false');
$file->close();
}
} catch(\Document\DocumentException $e){
$file = new File('files/playground/test_file.xml', true, 0644);
$file->open();
$file->write($e->getMessage());
$file->close();
}
}
}
No comments:
Post a Comment