Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.53 KB | None | 0 0
  1. <?php
  2. include_once "/srv/www/user4645/data/www/werwolf.ttandora.24x7s.com/bot/bd/nastr.php";
  3. include "/srv/www/user4645/data/www/werwolf.ttandora.24x7s.com/bot/obrabotka_zaprozow/taken.php";
  4. $para = array('peer_id' => "{$peer_id}",'type' => 'audio_message','access_token' => $token,'v' => $v);
  5. $para2 = http_build_query($para);
  6. $res = json_decode(file_get_contents(
  7. "https://api.vk.com/method/docs.getMessagesUploadServer?" . $para2));
  8. $res1 = $res->response->upload_url;
  9. $result = curl(
  10. 'https://tts.api.cloud.yandex.net/speech/v1/tts:synthesize',
  11. ['Authorization: Bearer '.$iam_token, 'Transfer-Encoding: chunked'],
  12. 'voice='.$golos.'&emotion='.$emotion2.'&format=oggopus&folderId='.$folder_id.'&text='.urlencode($text4));
  13. global $result;
  14. function curl($url, $headers = null, $post = null)
  15. {if ($ch1 = curl_init())
  16. {curl_setopt($ch1, CURLOPT_URL, $url);
  17. curl_setopt($ch1, CURLOPT_HEADER, false);
  18. curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
  19. if (! empty($headers))
  20. {curl_setopt($ch1, CURLOPT_HTTPHEADER, $headers);}
  21. if (! empty($post))
  22. {curl_setopt($ch1, CURLOPT_POST, true);
  23. curl_setopt($ch1, CURLOPT_POSTFIELDS, $post);}
  24. $result = curl_exec($ch1);
  25. curl_close($ch1);
  26. return $result;}
  27. return false;}
  28. $im = rand(1, 2000).'.ogg';
  29. file_put_contents($im, $result); //сохраняю
  30. $file = __DIR__ ."/../$im";
  31. $file = curl_file_create($file, mime_content_type($file), pathinfo($file)['basename']);
  32. $curl = curl_init();
  33. curl_setopt($curl, CURLOPT_URL, $res1);
  34. curl_setopt($curl, CURLOPT_POST, true);
  35. curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: multipart/form-data'));
  36. curl_setopt($curl, CURLOPT_POSTFIELDS, ['file' => $file]);
  37. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  38. curl_setopt($curl, CURLOPT_TIMEOUT, 1500);
  39. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  40. $six = json_decode(curl_exec($curl));
  41. $sax = $six->file;
  42. $pam = http_build_query(array(
  43. 'file' => $sax,
  44. 'access_token' => $token,
  45. 'v' => $v));
  46. $sexi = json_decode(file_get_contents(
  47. "https://api.vk.com/method/docs.save?" . $pam), true);
  48. $owner_id = $sexi["response"]["audio_message"]["owner_id"];
  49. $id = $sexi["response"]["audio_message"]["id"];
  50. $fhoto_i = "audio_message{$owner_id}_{$id}";
  51. $request_params = array('attachment' => $fhoto_i,'random_id' => "{$kod2}",'peer_id' => $peer_id,'access_token' => $token,'v' => $v);
  52. $get_params = http_build_query($request_params);
  53. file_get_contents('https://api.vk.com/method/messages.send?'. $get_params);
  54. unlink("/srv/www/user4645/data/www/werwolf.ttandora.24x7s.com/bot/$im");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement