Answer the question
In order to leave comments, you need to log in
VK API captcha not sent correctly?
Why do I send the answer to the captcha, and he only answers me with a new captcha
function friends_add () {
global $token;
global $userid;
foreach ($userid as $item) {
$url = "https://api.vk.com/method/friends.add?user_id=$item&access_token=$token&v=5.92";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
$res = json_decode($res, true);
if ($res['response'] == 1) {
echo "Заявка $item отправлена<br>";
} else if ($res['error']['error_code'] == 14) {
$sid = $res['error']['captcha_sid'];
echo "<img src=\"http:\/\/api.vk.com\/captcha.php?sid={$sid}&s=1\" alt=\"\">";
echo '<form name="form" method="post"> <input type="text" name="cap" id="cap"> </form>';
$cap_ans = $_POST['cap'];
if (!empty($_POST['cap'])) {
$url = "https://api.vk.com/method/friends.add?user_id=$item&captcha_sid=$sid&captcha_key=$cap_ans&access_token=$token&v=5.92";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
$res = json_decode($res, true);
var_dump($res);
break;
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question