Answer the question
In order to leave comments, you need to log in
Sending a VKontakte message curl how to deal with captcha?
The script works every half an hour sends a message about the status of the server to the same id.
Yesterday it worked, about 10 messages were received, and now the result requires you to enter a captcha. I tried the same garbage from other accounts.
How to get rid of the captcha check?
The error is returned in $response:
{"error":{"error_code":14,"error_msg":"Captcha needed","request_params":[{"key":"oauth","value":"1"},{"key":"method","value":"messages.getLongPollServer"}],"captcha_sid":"166193575288","captcha_img":"http:\/\/api.vk.com\/captcha.php?sid=166193575288","need_validation":1}}
$url ="https://api.vk.com/method/messages.send?access_token=".$token."&message=".$message."&uid=".$uid."&v=3&captcha_sid=&captcha_key=";
function curl( $url ) {
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
$response = curl_exec( $ch );
echo $response;
curl_close( $ch );
return json_decode($response , true);
}
curl( $url );
Answer the question
In order to leave comments, you need to log in
I was looking for a solution to this problem for a long time, by chance it was solved after the hoster transferred the site on which the script with the VK API worked from the server of Ukraine to the server in Germany.
The script stopped working and began to request captcha at the first access to VK.
But while the site was on a server in Ukraine, everything worked fine, I installed this script on another site that was on a server in Ukraine and voila - everything works.
Asking why? Yes, because the token was received by a user whose IP was Ukrainian and the script worked from the Ukrainian IP.
What I did was get a token using a German IP.
I went through the German proxy server in VK, received a token, entered a new token in the script settings and it all worked.
From this we conclude that the token must be received from the same country where the script or program is running.
If they do not match, then the VK protection system is triggered and they are asked to enter a captcha.
There are actually only two options:
1) Enter the captcha yourself
2) antigate.com
The second is the easiest.
Yes, it can be easier.
Send a message to your e-mail from a contact somewhere. The senders will have something like {user}-{hash}@vkmessenger.com
And then on the server just send classic mail. The message will come to Vkontakte without any trouble with api and captcha.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question