Код: Выделить всё
var url = "http://example.com/api/post";
var data = {
"statusCode": 200,
"statusLine": "HTTP/1.1 200",
"tabId": 1560,
"timeStamp": 1526986166702.353,
"type": "xmlhttprequest",
"url": "https://vk.com/al_search.php"
};
var json = JSON.stringify(data);
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader('Content-type','application/json; charset=utf-8');
xhr.onload = function () {
}
xhr.send(json);
Код: Выделить всё
class ApiController extends Controller
{
public function actionPost()
{
$this->enableCsrfValidation = false;
file_put_contents("sxsx.json", Yii::$app->request->post());
echo "SUCCESS";
}