student project

取得William 的資源

05 Jul 2016

下面是 python3 的範例 裡面有我的key 理論上只要我人在這邊,應該都可以取到資料

python3 : Get all resource

#!/usr/bin/env python3
############################################
# getAllResource.py
# Author: William Ho
# Date: 2016/06
# Brief: Get current endpoints from mbed Device Connector with API
############################################

from urllib.request import Request, urlopen

print("We will get all activity endpoints...")

URI='https://api.connector.mbed.com/endpoints/b963e35d-2f14-4142-a556-1e0e45cf0efc/'
AUTH_MSG ='Authorization' 
AUTH_VALUE = 'Bearer raMSWYiC6FCDp3EKU0JjI2CBG4oYDQvt3Bv58hKKWBwPIwf24AxEE1syhaM1npHFC5jQr5QMkGDKsQXotCNDDj6nGNC32sKX8vYA'

req = Request(URI)
req.add_header(AUTH_MSG, AUTH_VALUE)
data = urlopen(req)

print(data.read())
print("\n\nThat's all")

順利的話可以拿到這樣的結果

Note

We will get all activity endpoints... b'[{"uri":"/analog_sensor/0/axis_sensor","rt":"Sensor","obs":true,"type":""},{"uri":"/led_blink/0/blinker","rt":"Blink","obs":false,"type":""},{"uri":"/led_blink/0/blink_4times","rt":"Pattern","obs":false,"type":""},{"uri":"/digital_inp/0/buttoni_1","rt":"Button","obs":true,"type":""},{"uri":"/3/0","obs":false,"type":""}]'

06 Jul 2016

現在可以到SVN 取得我的資料 這是用 https://github.com/ARMmbed/mbed-connector-api-python-quickstart 修改的 請到這裡下載 svn:220.135.48.146/19_Stuproj/mymbed/trunk/git/mbed-connector-api-python