There was a problem with php: // input. I wanted to write a bot for VK, in the documentation there is the following line:
$data = json_decode(file_get_contents('php://input')); But it just does not work. When you try to get something (for example, output via echo or var_dump) it produces NULL. It is logical to add a GET request to the string, and get some kind of answer (I guess so), but still nothing.
Wrote a jQuery test:
function testVk(){ var markers = {"type":"confirmation","group_id":111,"secret":"test"}; $.ajax({ type: "POST", url: "/sources/vk_bot.php", // data: markers, contentType: "application/json; charset=utf-8", dataType: "json", success: function(data){alert('OK: ' + data);}, failure: function(errMsg) { alert(errMsg); } }); } But with this, it leads to a null in response.
Everything is fine in php.ini:
allow_url_fopen = On What else could be wrong? Why am I not getting anything from the stream?
$data, butfile_get_contents('php://input'). There, most likely, the array is already ready, and when you try to decode it, you get NULL. - u_muldervar_dump(file_get_contents('php://input'))still produces string (0) "", although a GET request is present in the string. It is always the JSON request that is sent. - Vladimir Gonchar