-
-
Save ma2shita/a7f2a0acf9b1a7f43c360e1371aadaed to your computer and use it in GitHub Desktop.
SORACOM Funk test (using Unified Endpoint) (Let's try IoT Prototyping / MFT2020)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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