Skip to content

Instantly share code, notes, and snippets.

@ma2shita
Last active August 31, 2020 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ma2shita/a7f2a0acf9b1a7f43c360e1371aadaed to your computer and use it in GitHub Desktop.
Save ma2shita/a7f2a0acf9b1a7f43c360e1371aadaed to your computer and use it in GitHub Desktop.
SORACOM Funk test (using Unified Endpoint) (Let's try IoT Prototyping / MFT2020)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import json
import base64
from subprocess import Popen, PIPE
def main():
headers = {'Content-Type': 'application/json'}
payload = json.dumps({})
response = urllib2.urlopen(urllib2.Request('http://uni.soracom.io', payload, headers))
print(response.getcode())
body = json.loads(response.read())
mp3data = base64.b64decode(body['data'])
cp = Popen(['mpg123', '-'], stdin=PIPE)
cp.communicate(input=mp3data)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment