Guest User

Untitled

a guest
Aug 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. public function GetAttachment($MessageGroupID, $MessageUid, $ContentKey = "image-data-0", $ContentType = "image/jpeg")
  2. {
  3.     $headers = array(
  4.         'Authorization: Bearer ' . $this->oauth,
  5.         'Content-Type: ' . $ContentType,
  6.         'Content-Transfer-Encoding: binary'
  7.     );
  8.     $response = \Utilities::SendRequest(MESSAGE_URL . '/' . $MessageGroupID . '/messages/' . $MessageUid . '?contentKey=' . $ContentKey, $headers, false, null, "GET", null);
  9.  
  10.  
  11.     $data = base64_encode($response['body']);
  12.  
  13.     return $data;
  14. }
  15.  
  16. // Get Audio
  17. if (!file_exists($FullAudio))
  18. {
  19.     $AudioData = base64_decode($MessageAPI->GetAttachment($MessageGroupID, $Messages->messages[$i]->messageUid, "voice-data-0", "audio/mpeg"));
  20.     $fp = fopen($FullAudio, 'x');
  21.     fwrite($fp, $AudioData);
  22.     fclose($fp);
  23. }
  24.  
  25. // Set Path to Audio
  26. $Audio = '<audio controls>';
  27.     $Audio .= '<source src="/psn/audio/' . $FullAudioName . '" type="audio/mpeg">';  
  28.     $Audio .= 'Your browser does not support the audio tag.';
  29. $Audio .= '</audio>';
  30. $Content .= $Audio;
Add Comment
Please, Sign In to add comment