I want to send a request to create a post in the VC group, yesterday I literally worked, now it gives 400 bad request.
The most important thing is that if I display a variable on the screen, insert it into the address bar, then everything works.

$url2 = "https://api.vk.com/method/wall.post?owner_id=".$params["group_id"]."&from_group=".$params["from_group"]."&message=".$message."&v=".$params["v"]."&access_token=".$params["access_token"]; echo $url2; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url2); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $r = curl_exec($ch); curl_close($ch); 

    1 answer 1

    It was all in the $message variable
    Its view is: $message = "New post on group wall"; Apparently just the spaces were not converted. Because without spaces, the request passed.
    For this, I simply added this line:

     curl_setopt($ch, CURLOPT_POSTFIELDS, "message= $message"); 

    That's all.
    Yesterday it worked, because I sent the request without spaces.
    Why it worked, and why there was a problem because of spaces, I can not explain. I don't know enough curl myself :)