Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tokenVK($login, $password, $atom) {
- $token_url = $atom->request([
- 'url' => 'https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username='.$login.'&password='.$password,
- 'no_headers' => true,
- ]);
- $token_url = json_decode($token_url);
- //-----------------Ввод капчи, если запросили--------------
- if($token_url->captcha_sid){
- $ch = curl_init($result->captcha_img);
- $fp = fopen('captcha.png', 'wb');
- curl_setopt($ch, CURLOPT_FILE, $fp);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_exec($ch);
- curl_close($ch);
- fclose($fp);
- $imgcap = 'captcha.png';
- try {
- $code = $atom->ruCaptcha($imgcap, [
- 'regsense' => 1,
- ]);
- }
- catch (Exception $e) {
- $error_capt = 'Выброшено исключение: '. $e->getMessage();
- }
- $token_url = $atom->request([
- 'url' => 'https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username='.$login.'&password='.$password.'&captcha_sid='.$result->captcha_sid.'&captcha_key='.$code,
- 'no_headers' => true,
- ]);
- $token_url = json_decode($token_url);
- }
- elseif ($token_url->error_description){
- echo "Ошибка данных!!!";
- return;
- }
- test($token_url);
- unlink(__DIR__ .'/tmp/atomic.cookie');
- return $token_url->access_token;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement