Cakephp 3.x и принятие сторонних данных XML

Наши клиенты отправляют документы третьим лицам и хранят их. Как только третье лицо получает документы, они отправляют данные XML на наш URL-адрес, который мы им предоставляем (например, https://example.com/Documents/receive). Наша третья сторона требует, чтобы мы отправили им ответ о том, что мы получили их запрос. Мы создали библиотеку поставщиков и включили ее в наше приложение. По какой-то причине, когда мы подделываем запрос от третьей стороны, мы получаем перенаправление обратно на страницу входа, как будто ничего не произошло. Это наш контроллер.

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();
}
}
}

0

Решение

Кажется, что-то не так с кулинарной книгой. Попробуй это:

public function beforeFilter(Event $event) {
parent::beforeFilter($event);
$this->Auth->allow(['receive']);
}
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector